Print

Print


Author: [log in to unmask]
Date: Wed Apr 27 12:23:44 2016
New Revision: 4348

Log:
Code formatting; convert tabs to spaces.

Modified:
    java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/base/StatFunUtils.java
    java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/crystal/Crystal.java
    java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/crystal/CrystalTaitBryanAngleCalculator.java
    java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/crystal/Geant4Position.java
    java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/ecal/Transformations.java
    java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/CenterMass.java
    java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/Line.java
    java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/Plane.java
    java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/Vector.java
    java/branches/HPSJAVA-409/detector-model/src/main/java/org/lcsim/detector/converter/compact/HPSEcal4Converter.java
    java/branches/HPSJAVA-409/detector-model/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSEcal4.java
    java/branches/HPSJAVA-409/detector-model/src/main/java/org/lcsim/geometry/subdetector/HPSEcal4.java

Modified: java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/base/StatFunUtils.java
 =============================================================================
--- java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/base/StatFunUtils.java	(original)
+++ java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/base/StatFunUtils.java	Wed Apr 27 12:23:44 2016
@@ -1,35 +1,27 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-
 package org.hps.detector.ecal.geo2015.base;
 
 /**
  * Some static functions, well, just one
+ * 
  * @author SA
  */
 public class StatFunUtils {
- 
-	/*****
-     * Function to doubles to rounds up the value
-     *  to 'places' digits after the ","
-     * ******/  
+
+    /*****
+     * Function to doubles to rounds up the value to 'places' digits after the ","
+     ******/
     public static double round(double value, int places) {
-        if (places < 0 || places>16) {
+        if (places < 0 || places > 16) {
             throw new IllegalArgumentException();
         }
         long factor = (long) Math.pow(10, places);
-        //System.out.println(factor+"   val = "+value);
+        // System.out.println(factor+"   val = "+value);
         value = value * factor;
-       // System.out.println("again "+value);
+        // System.out.println("again "+value);
         long tmp = Math.round(value);
-        //System.out.println("tmp = "+tmp);
-       // System.out.println((double) tmp / factor);
+        // System.out.println("tmp = "+tmp);
+        // System.out.println((double) tmp / factor);
         return (double) tmp / factor;
     }
-    
-    
+
 }

Modified: java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/crystal/Crystal.java
 =============================================================================
--- java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/crystal/Crystal.java	(original)
+++ java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/crystal/Crystal.java	Wed Apr 27 12:23:44 2016
@@ -1,39 +1,39 @@
 package org.hps.detector.ecal.geo2015.crystal;
 
+public class Crystal {
 
-public class Crystal{
-	
-	private int layer; 
-	private int column;
-	private Geant4Position pos;
-	
-	public Crystal(int icol, int ilayer, Geant4Position ipos){
-		this.layer = ilayer;
-		this.column = icol;
-		this.pos = ipos;
-	}
-	
-	public Geant4Position  getCrystalG4Pos(){
-		return this.pos;
-	}
-	
-	public int getLayer(){
-		return this.layer;
-	}
-	
-	public int getColumn(){
-		return this.column;
-	}
-	
-	public void setLayer(int ilayer){
-		this.layer=ilayer;
-	}
-	
-	public void setColumn(int icol){
-		 this.column=icol;
-	}
-	public void setG4Position(Geant4Position ipos){
-		this.pos = ipos;
-	}
-	
+    private int layer;
+    private int column;
+    private Geant4Position pos;
+
+    public Crystal(int icol, int ilayer, Geant4Position ipos) {
+        this.layer = ilayer;
+        this.column = icol;
+        this.pos = ipos;
+    }
+
+    public Geant4Position getCrystalG4Pos() {
+        return this.pos;
+    }
+
+    public int getLayer() {
+        return this.layer;
+    }
+
+    public int getColumn() {
+        return this.column;
+    }
+
+    public void setLayer(int ilayer) {
+        this.layer = ilayer;
+    }
+
+    public void setColumn(int icol) {
+        this.column = icol;
+    }
+
+    public void setG4Position(Geant4Position ipos) {
+        this.pos = ipos;
+    }
+
 }

Modified: java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/crystal/CrystalTaitBryanAngleCalculator.java
 =============================================================================
--- java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/crystal/CrystalTaitBryanAngleCalculator.java	(original)
+++ java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/crystal/CrystalTaitBryanAngleCalculator.java	Wed Apr 27 12:23:44 2016
@@ -1,23 +1,21 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * To change this license header, choose License Headers in Project Properties. To change this template file, choose
+ * Tools | Templates and open the template in the editor.
  */
 package org.hps.detector.ecal.geo2015.crystal;
 
 import org.hps.detector.ecal.geo2015.geoutils.Vector;
 
 /**
- * Calculates Euler(actually tait-bryan) angles for a rotation, that transfers the crystal from it's
- * initial state-parallel to Z axis To final state-defined by 2 points in front
- * and back faces.
+ * Calculates Euler(actually tait-bryan) angles for a rotation, that transfers the crystal from it's initial
+ * state-parallel to Z axis To final state-defined by 2 points in front and back faces.
  *
  * @author SA
  */
 public class CrystalTaitBryanAngleCalculator {
 
-    private  double phi=0;
-    private  double theta=0;
+    private double phi = 0;
+    private double theta = 0;
     private final double psi = 0;
 
     private static final Vector ini = new Vector(0, 0, 1);
@@ -31,35 +29,33 @@
 
     public CrystalTaitBryanAngleCalculator(Vector vec_fin) {
 
-        fin = vec_fin;      
-        if (vec_fin.isUnitary() == false) {          
+        fin = vec_fin;
+        if (vec_fin.isUnitary() == false) {
             fin = vec_fin.getUnitVector();
         }
-                 
+
         this.phi = this.CalcPhi();
-        this.theta = this.CalcTheta();      
+        this.theta = this.CalcTheta();
     }
 
-    
-    private double CalcPhi(){
-    	
-    	sinPhi = -fin.y ;
-    	cosPhi = Math.sqrt(1-this.sinPhi*this.sinPhi);
-    	
-    	return Math.asin(this.sinPhi);
-    } 
-  
-    private double CalcTheta(){
-    	
-    	if(this.cosPhi==0)
-    		this.sinTheta=Double.NaN;
-    	else
-    		this.sinTheta = fin.x/this.cosPhi; 
-    	
-    	return Math.asin(this.sinTheta);
+    private double CalcPhi() {
+
+        sinPhi = -fin.y;
+        cosPhi = Math.sqrt(1 - this.sinPhi * this.sinPhi);
+
+        return Math.asin(this.sinPhi);
     }
-    
- 
+
+    private double CalcTheta() {
+
+        if (this.cosPhi == 0)
+            this.sinTheta = Double.NaN;
+        else
+            this.sinTheta = fin.x / this.cosPhi;
+
+        return Math.asin(this.sinTheta);
+    }
+
     public double getTheta() {
         return this.theta;
     }

Modified: java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/crystal/Geant4Position.java
 =============================================================================
--- java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/crystal/Geant4Position.java	(original)
+++ java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/crystal/Geant4Position.java	Wed Apr 27 12:23:44 2016
@@ -3,10 +3,9 @@
 import org.hps.detector.ecal.geo2015.geoutils.Vector;
 
 /**
- * Calculates G4 position for a crystal, by it's front and back face coordinates 
- *  calculates the position for the center of the crystal 
- *  calculates the rotation of the crystal in convention of Tait-Bryan angles, {phi, theta, psi}
- * ***** dear reader google it if confused :P 
+ * Calculates G4 position for a crystal, by it's front and back face coordinates calculates the position for the center
+ * of the crystal calculates the rotation of the crystal in convention of Tait-Bryan angles, {phi, theta, psi} *****
+ * dear reader google it if confused :P
  * 
  * @author SA
  */
@@ -14,14 +13,14 @@
 
     private Vector centerPoint;
     private Vector crysvec;
-    private double[] taitbriangles; //{ phi,theta,psi=0};
-    private double[] center_arr; 
-    
+    private double[] taitbriangles; // { phi,theta,psi=0};
+    private double[] center_arr;
+
     public Geant4Position(Vector point1, Vector point2) {
 
-    	if(point1==null || point2==null)
-    		System.err.println("The arguments can't be 0.");
-    	
+        if (point1 == null || point2 == null)
+            System.err.println("The arguments can't be 0.");
+
         centerPoint = point2.Add(point1).Multiply(0.5);
         center_arr = new double[3];
         center_arr[0] = centerPoint.x;
@@ -31,35 +30,35 @@
         System.out.println("*************** center unit vector **********");
         crysvec.Print();
         System.out.println("*********************************************");
- 
+
         taitbriangles = new double[3];
         this.TaitBryanAnglesforCrys();
-       
+
     }
 
     public Vector getCenter() {
         return this.centerPoint;
     }
-        
+
     public double[] getCenterArr() {
-    	double [] center_arr = {centerPoint.x,centerPoint.y,centerPoint.z};
+        double[] center_arr = {centerPoint.x, centerPoint.y, centerPoint.z};
         return center_arr;
     }
+
     public double[] getTaitBryanAngles() {
         return this.taitbriangles;
     }
 
     private void TaitBryanAnglesforCrys() {
-    	CrystalTaitBryanAngleCalculator crysTBang = new CrystalTaitBryanAngleCalculator(crysvec);
+        CrystalTaitBryanAngleCalculator crysTBang = new CrystalTaitBryanAngleCalculator(crysvec);
         /*
-        * please vec should go from the center, even though it's not changing much
-        */
+         * please vec should go from the center, even though it's not changing much
+         */
 
         if (crysTBang.getPhi() == Double.NaN) {
             System.out.print("chert: Phi is undefined\n");
             this.taitbriangles[0] = -111111;
-        }
-        else {
+        } else {
             this.taitbriangles[0] = -crysTBang.getPhi();
         }
         this.taitbriangles[1] = -crysTBang.getTheta();
@@ -69,7 +68,8 @@
     public void Print() {
         System.out.println("Crys Center coordinates:\t");
         this.centerPoint.Print();
-        System.out.println("Tait Brian angles phi = " + Math.toDegrees(this.taitbriangles[0]) + "\t theta = " + Math.toDegrees(this.taitbriangles[1]) + "\t psi = " + Math.toDegrees(this.taitbriangles[2]) + "\n");
+        System.out.println("Tait Brian angles phi = " + Math.toDegrees(this.taitbriangles[0]) + "\t theta = "
+                + Math.toDegrees(this.taitbriangles[1]) + "\t psi = " + Math.toDegrees(this.taitbriangles[2]) + "\n");
     }
 
 }

Modified: java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/ecal/Transformations.java
 =============================================================================
--- java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/ecal/Transformations.java	(original)
+++ java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/ecal/Transformations.java	Wed Apr 27 12:23:44 2016
@@ -1,10 +1,8 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * To change this license header, choose License Headers in Project Properties. To change this template file, choose
+ * Tools | Templates and open the template in the editor.
  */
 package org.hps.detector.ecal.geo2015.ecal;
-
 
 import org.hps.detector.ecal.geo2015.geoutils.Vector;
 import org.hps.detector.ecal.geo2015.base.DataLoader;
@@ -17,152 +15,158 @@
 import java.util.HashMap;
 
 /**
- * Class does all the transformations to rotate and translate the modules of ecal by given arguments from rel to it's nominal pos.
- * An issue is, that once a module is transformed, the non modified module map remains undefined
- * This needs to be fixed or not?
- * Has bunch of printouts for debuging, will be removed soon, I hope soon :/
+ * Class does all the transformations to rotate and translate the modules of ecal by given arguments from rel to it's
+ * nominal pos. An issue is, that once a module is transformed, the non modified module map remains undefined This needs
+ * to be fixed or not? Has bunch of printouts for debuging, will be removed soon, I hope soon :/
+ * 
  * @author SA
  */
 public class Transformations {
 
-	public Vector transVec;
-	public double[] rotation;
-	private String module;// top or bottom or all
-	private Vector CMvec_nom_top = new Vector(109.88, 230.79, 1008.73);
-	private Vector CMvec_nom_bot = new Vector(109.88, -230.79, 1008.73);
+    public Vector transVec;
+    public double[] rotation;
+    private String module;// top or bottom or all
+    private Vector CMvec_nom_top = new Vector(109.88, 230.79, 1008.73);
+    private Vector CMvec_nom_bot = new Vector(109.88, -230.79, 1008.73);
 
-	private Map<String, Crystal> crystalMap;
-	
-	public Transformations(String module, double [] trans , double [] rot){
-		System.out.println(module);
-		System.out.println("trans arg "+trans[0]+"\t"+trans[1]+"\t"+trans[2]);
-		System.out.println("rot arg "+rot[0]+"\t"+rot[1]+"\t"+rot[2]);
-		this.transVec = new Vector(trans);
-		transVec.Print();
-		this.rotation = rot;	
-		System.out.println("rotation "+this.rotation[0]+"\t"+this.rotation[1]+"\t"+this.rotation[2]);
-		this.module = module;
-		this.crystalMap = new HashMap<String, Crystal>();
-		try{ this.makeTransformation();}
-		catch(IOException e){System.err.print("Can't do transformations, for some reason   "+crystalMap.size());}
-	}
+    private Map<String, Crystal> crystalMap;
 
-	public Map<String, Crystal>  getCrystalMap() {
-		return this.crystalMap;
-	}
+    public Transformations(String module, double[] trans, double[] rot) {
+        System.out.println(module);
+        System.out.println("trans arg " + trans[0] + "\t" + trans[1] + "\t" + trans[2]);
+        System.out.println("rot arg " + rot[0] + "\t" + rot[1] + "\t" + rot[2]);
+        this.transVec = new Vector(trans);
+        transVec.Print();
+        this.rotation = rot;
+        System.out.println("rotation " + this.rotation[0] + "\t" + this.rotation[1] + "\t" + this.rotation[2]);
+        this.module = module;
+        this.crystalMap = new HashMap<String, Crystal>();
+        try {
+            this.makeTransformation();
+        } catch (IOException e) {
+            System.err.print("Can't do transformations, for some reason   " + crystalMap.size());
+        }
+    }
 
-	private void makeTransformation() throws IOException{
-		DataLoader data = new DataLoader();
+    public Map<String, Crystal> getCrystalMap() {
+        return this.crystalMap;
+    }
 
-		data.setSplitSimbol("\t");
-		data.LoadData("/projet/nucleon2/annie/HPS/withHPS_Java/SENA/hps_trunk_dev/HPSJAVA_409anothercopy02_02_2016/detector-model/src/main/java/org/hps/detector/ecal/geo2015/data/Crystal_COORDINATES_relTarget.txt");
-		System.out.println("FILE PATHHHHHH    "+ ( new File(".").getAbsolutePath().toString() )  );
-		System.out.println("FILE PATH11111    "+ System.getProperty("user.dir")+"/src/main/java/org/hps/detector/ecal/geo2015/data/Crystal_COORDINATES_relTarget.txt");
-	
-		//data.LoadData(System.getProperty("user.dir")+"/src/main/java/org/hps/detector/ecal/geo2015/data/Crystal_COORDINATES_relTarget.txt");		
-		//data.LoadData(FileSystems.getDefault().getPath("data", "Crystal_COORDINATES_relTarget.txt").toString()); 
-		System.out.println("Number of coloms read from the file  = " + data.getNumberCols());
+    private void makeTransformation() throws IOException {
+        DataLoader data = new DataLoader();
 
-		Double[] N = data.getColumn(0);
-		Double[] layer = data.getColumn(1);
-		Double[] col = data.getColumn(2);
-		Double[] Xfront = data.getColumn(3);
-		Double[] Yfront = data.getColumn(4);
-		Double[] Zfront = data.getColumn(5);
-		Double[] Xback = data.getColumn(6);
-		Double[] Yback = data.getColumn(7);
-		Double[] Zback = data.getColumn(8);
+        data.setSplitSimbol("\t");
+        data.LoadData("/projet/nucleon2/annie/HPS/withHPS_Java/SENA/hps_trunk_dev/HPSJAVA_409anothercopy02_02_2016/detector-model/src/main/java/org/hps/detector/ecal/geo2015/data/Crystal_COORDINATES_relTarget.txt");
+        System.out.println("FILE PATHHHHHH    " + (new File(".").getAbsolutePath().toString()));
+        System.out.println("FILE PATH11111    " + System.getProperty("user.dir")
+                + "/src/main/java/org/hps/detector/ecal/geo2015/data/Crystal_COORDINATES_relTarget.txt");
 
-		// data.Print();
-		Vector[] frontXYZ = new Vector[N.length];
-		Vector[] backXYZ = new Vector[N.length];
+        // data.LoadData(System.getProperty("user.dir")+"/src/main/java/org/hps/detector/ecal/geo2015/data/Crystal_COORDINATES_relTarget.txt");
+        // data.LoadData(FileSystems.getDefault().getPath("data", "Crystal_COORDINATES_relTarget.txt").toString());
+        System.out.println("Number of coloms read from the file  = " + data.getNumberCols());
 
-		Vector CMvec_nom = new Vector();
+        Double[] N = data.getColumn(0);
+        Double[] layer = data.getColumn(1);
+        Double[] col = data.getColumn(2);
+        Double[] Xfront = data.getColumn(3);
+        Double[] Yfront = data.getColumn(4);
+        Double[] Zfront = data.getColumn(5);
+        Double[] Xback = data.getColumn(6);
+        Double[] Yback = data.getColumn(7);
+        Double[] Zback = data.getColumn(8);
 
-	/*	File wfile = new File("../data/output_relTarget.txt");
-		FileWriter fw = new FileWriter(wfile.getAbsoluteFile());
-		BufferedWriter bw = new BufferedWriter(fw);
-		bw.write("#column /t #layer /t #front_faceX /t #front_faceY /t #front_faceZ /t #back_faceX /t #back_faceY /t #back_faceZ \n");
-*/
-		// translate the coordinate system to CM
-		for (int loop = 0; loop < N.length; loop++) {
-		
+        // data.Print();
+        Vector[] frontXYZ = new Vector[N.length];
+        Vector[] backXYZ = new Vector[N.length];
 
-			if (this.module.compareToIgnoreCase("bottom")==0 && layer[loop] > 0) {
-				//crystalMap.put(String.format("c%d:l%d", col[loop].intValue(), layer[loop].intValue()),
-					//	new Crystal(col[loop].intValue(), layer[loop].intValue(),
-							//	new Geant4Position(frontXYZ[loop], backXYZ[loop])));
-				continue;
-			} else if (this.module.compareToIgnoreCase("top")==0 && layer[loop] < 0) {
-				//crystalMap.put(String.format("c%d:l%d", col[loop].intValue(), layer[loop].intValue()),
-					//	new Crystal(col[loop].intValue(), layer[loop].intValue(),
-						//		new Geant4Position(frontXYZ[loop], backXYZ[loop])));
-				continue;
-			}
-			frontXYZ[loop] = new Vector(Xfront[loop], Yfront[loop], Zfront[loop]);
-			backXYZ[loop] = new Vector(Xback[loop], Yback[loop], Zback[loop]);
-		
-			System.out.println("Initial position");
-			frontXYZ[loop].Print();
-			backXYZ[loop].Print();
-			
-			if (layer[loop] > 0) {                                                                                                                         
-				CMvec_nom = CMvec_nom_top;
-			} else if (layer[loop] < 0) {
-				CMvec_nom = CMvec_nom_bot;
-			}
+        Vector CMvec_nom = new Vector();
 
-			// translate by the vector = center of coordinate system, I mean
-			// where the ecal is.			
-			frontXYZ[loop] = frontXYZ[loop].TranslateBy(CMvec_nom.getOpposite());
-			backXYZ[loop] = backXYZ[loop].TranslateBy(CMvec_nom.getOpposite());
-			//frontXYZ[loop] = frontXYZ[loop].TranslateBy(CMvec_nom);
-			//backXYZ[loop] = backXYZ[loop].TranslateBy(CMvec_nom);
+        /*
+         * File wfile = new File("../data/output_relTarget.txt"); FileWriter fw = new
+         * FileWriter(wfile.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write(
+         * "#column /t #layer /t #front_faceX /t #front_faceY /t #front_faceZ /t #back_faceX /t #back_faceY /t #back_faceZ \n"
+         * );
+         */
+        // translate the coordinate system to CM
+        for (int loop = 0; loop < N.length; loop++) {
 
-			CMvec_nom.Print();
-			System.out.println("after translation to CM COO-system");
-			// frontXYZ[loop].Print();
-			// backXYZ[loop].Print();
+            if (this.module.compareToIgnoreCase("bottom") == 0 && layer[loop] > 0) {
+                // crystalMap.put(String.format("c%d:l%d", col[loop].intValue(), layer[loop].intValue()),
+                // new Crystal(col[loop].intValue(), layer[loop].intValue(),
+                // new Geant4Position(frontXYZ[loop], backXYZ[loop])));
+                continue;
+            } else if (this.module.compareToIgnoreCase("top") == 0 && layer[loop] < 0) {
+                // crystalMap.put(String.format("c%d:l%d", col[loop].intValue(), layer[loop].intValue()),
+                // new Crystal(col[loop].intValue(), layer[loop].intValue(),
+                // new Geant4Position(frontXYZ[loop], backXYZ[loop])));
+                continue;
+            }
+            frontXYZ[loop] = new Vector(Xfront[loop], Yfront[loop], Zfront[loop]);
+            backXYZ[loop] = new Vector(Xback[loop], Yback[loop], Zback[loop]);
 
-			/// Rotate the modules by angle calc from suvey data
-			frontXYZ[loop] = frontXYZ[loop].RotateBy(this.rotation[0], this.rotation[1], this.rotation[2]);
-			backXYZ[loop] = backXYZ[loop].RotateBy(this.rotation[0], this.rotation[1], this.rotation[2]);
+            System.out.println("Initial position");
+            frontXYZ[loop].Print();
+            backXYZ[loop].Print();
 
-			System.out.println("after module plane rotation");
-			//frontXYZ[loop].Print();
-			//backXYZ[loop].Print();
+            if (layer[loop] > 0) {
+                CMvec_nom = CMvec_nom_top;
+            } else if (layer[loop] < 0) {
+                CMvec_nom = CMvec_nom_bot;
+            }
 
-			// Translate modules by the translation vector the diff of CM			
-			frontXYZ[loop] = frontXYZ[loop].TranslateBy(transVec);
-			backXYZ[loop] = backXYZ[loop].TranslateBy(transVec);
+            // translate by the vector = center of coordinate system, I mean
+            // where the ecal is.
+            frontXYZ[loop] = frontXYZ[loop].TranslateBy(CMvec_nom.getOpposite());
+            backXYZ[loop] = backXYZ[loop].TranslateBy(CMvec_nom.getOpposite());
+            // frontXYZ[loop] = frontXYZ[loop].TranslateBy(CMvec_nom);
+            // backXYZ[loop] = backXYZ[loop].TranslateBy(CMvec_nom);
 
-			System.out.println("after translation by survey shift");
-			// frontXYZ[loop].Print();
-			// backXYZ[loop].Print();
+            CMvec_nom.Print();
+            System.out.println("after translation to CM COO-system");
+            // frontXYZ[loop].Print();
+            // backXYZ[loop].Print();
 
-			/// Translate back to initial coordinate system
-			frontXYZ[loop] = frontXYZ[loop].TranslateBy(CMvec_nom);
-			backXYZ[loop] = backXYZ[loop].TranslateBy(CMvec_nom);
-			System.out.println("after translation back to initial system");
-			frontXYZ[loop].Print();
-			backXYZ[loop].Print();
+            // / Rotate the modules by angle calc from suvey data
+            frontXYZ[loop] = frontXYZ[loop].RotateBy(this.rotation[0], this.rotation[1], this.rotation[2]);
+            backXYZ[loop] = backXYZ[loop].RotateBy(this.rotation[0], this.rotation[1], this.rotation[2]);
 
-			/*bw.write(String.valueOf(col[loop].intValue()) + "\t" + String.valueOf(layer[loop].intValue()) + "\t"
-					+ String.valueOf(frontXYZ[loop].x) + "\t" + String.valueOf(frontXYZ[loop].y) + "\t"
-					+ String.valueOf(frontXYZ[loop].z) + "\t" + String.valueOf(backXYZ[loop].x) + "\t"
-					+ String.valueOf(backXYZ[loop].y) + "\t" + String.valueOf(backXYZ[loop].z) + "\n");*/
+            System.out.println("after module plane rotation");
+            // frontXYZ[loop].Print();
+            // backXYZ[loop].Print();
 
-			if(frontXYZ[loop]==null || backXYZ[loop]==null)
-	    		System.err.println("The vectors are 0? really? Should never happen");
-			
-			Geant4Position g4pos = new Geant4Position(frontXYZ[loop], backXYZ[loop]);
+            // Translate modules by the translation vector the diff of CM
+            frontXYZ[loop] = frontXYZ[loop].TranslateBy(transVec);
+            backXYZ[loop] = backXYZ[loop].TranslateBy(transVec);
 
-			crystalMap.put(String.format("c%d:l%d", col[loop].intValue(), layer[loop].intValue()),
-					new Crystal(col[loop].intValue(), layer[loop].intValue(), g4pos));
-			System.out.println("icol = "+col[loop].intValue()+" ilay = "+layer[loop].intValue());
-			g4pos.Print();
-		}
-		System.err.println("Number of map content Transformations   "+crystalMap.size());
-		
-	}
+            System.out.println("after translation by survey shift");
+            // frontXYZ[loop].Print();
+            // backXYZ[loop].Print();
+
+            // / Translate back to initial coordinate system
+            frontXYZ[loop] = frontXYZ[loop].TranslateBy(CMvec_nom);
+            backXYZ[loop] = backXYZ[loop].TranslateBy(CMvec_nom);
+            System.out.println("after translation back to initial system");
+            frontXYZ[loop].Print();
+            backXYZ[loop].Print();
+
+            /*
+             * bw.write(String.valueOf(col[loop].intValue()) + "\t" + String.valueOf(layer[loop].intValue()) + "\t" +
+             * String.valueOf(frontXYZ[loop].x) + "\t" + String.valueOf(frontXYZ[loop].y) + "\t" +
+             * String.valueOf(frontXYZ[loop].z) + "\t" + String.valueOf(backXYZ[loop].x) + "\t" +
+             * String.valueOf(backXYZ[loop].y) + "\t" + String.valueOf(backXYZ[loop].z) + "\n");
+             */
+
+            if (frontXYZ[loop] == null || backXYZ[loop] == null)
+                System.err.println("The vectors are 0? really? Should never happen");
+
+            Geant4Position g4pos = new Geant4Position(frontXYZ[loop], backXYZ[loop]);
+
+            crystalMap.put(String.format("c%d:l%d", col[loop].intValue(), layer[loop].intValue()), new Crystal(
+                    col[loop].intValue(), layer[loop].intValue(), g4pos));
+            System.out.println("icol = " + col[loop].intValue() + " ilay = " + layer[loop].intValue());
+            g4pos.Print();
+        }
+        System.err.println("Number of map content Transformations   " + crystalMap.size());
+
+    }
 }

Modified: java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/CenterMass.java
 =============================================================================
--- java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/CenterMass.java	(original)
+++ java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/CenterMass.java	Wed Apr 27 12:23:44 2016
@@ -1,14 +1,12 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * To change this license header, choose License Headers in Project Properties. To change this template file, choose
+ * Tools | Templates and open the template in the editor.
  */
 package org.hps.detector.ecal.geo2015.geoutils;
 
 /**
- * The Class is implemented to calculate not fairly called "center mass" Defined
- * as a Point with a coordinates as arithmetical mean of the corresponding
- * coordinates of points-arguments
+ * The Class is implemented to calculate not fairly called "center mass" Defined as a Point with a coordinates as
+ * arithmetical mean of the corresponding coordinates of points-arguments
  *
  * @author AS
  */
@@ -31,8 +29,7 @@
     }
 
     /*
-     * Meaningful constructor, for any number of points arguments should be
-     * arrays of (Xs[], Ys[], Zs[]) of points
+     * Meaningful constructor, for any number of points arguments should be arrays of (Xs[], Ys[], Zs[]) of points
      */
     public CenterMass(double[] x, double[] y, double[] z) {
 
@@ -67,7 +64,7 @@
     }
 
     public double[] getCMarray() {
-      double[] center = {this.xc, this.yc, this.zc};
-      return center;
+        double[] center = {this.xc, this.yc, this.zc};
+        return center;
     }
 }

Modified: java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/Line.java
 =============================================================================
--- java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/Line.java	(original)
+++ java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/Line.java	Wed Apr 27 12:23:44 2016
@@ -1,54 +1,45 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * To change this license header, choose License Headers in Project Properties. To change this template file, choose
+ * Tools | Templates and open the template in the editor.
  */
 
 package org.hps.detector.ecal.geo2015.geoutils;
 
 /**
- *
  * @author AS
  */
 public class Line {
-    
-    //private double  a=0, b=0, c=0; //ax+by+c=0
-    private Vector  vec_n; // napravlyayushiy vector
-    private double [] point;
-    
-   
-    //Define a line with a vector and a point it goes through
-    public Line(Vector vec, double x, double y, double z){
+
+    // private double a=0, b=0, c=0; //ax+by+c=0
+    private Vector vec_n; // napravlyayushiy vector
+    private double[] point;
+
+    // Define a line with a vector and a point it goes through
+    public Line(Vector vec, double x, double y, double z) {
         this.setVec_n(new Vector(vec.x, vec.y, vec.z));
-        point = new double [3];
-        point[0]=x;
-        point[1]=y;
-        point[2]=z;        
-    }
-    
-    
-    //Define a line that goes through 2 points, M0 and M1
-    public Line(Vector vecM0, Vector vecM1){        
-        setVec_n(vecM1.Substract(vecM0));
-        point = vecM0.getVector();                          
-    }
-    
-    public Vector getCenter(Vector vecM0, Vector vecM1){
-        
-        return (vecM1.Substract(vecM0)).Multiply(0.5);        
+        point = new double[3];
+        point[0] = x;
+        point[1] = y;
+        point[2] = z;
     }
 
+    // Define a line that goes through 2 points, M0 and M1
+    public Line(Vector vecM0, Vector vecM1) {
+        setVec_n(vecM1.Substract(vecM0));
+        point = vecM0.getVector();
+    }
 
-	public Vector getVec_n() {
-		return vec_n;
-	}
+    public Vector getCenter(Vector vecM0, Vector vecM1) {
 
+        return (vecM1.Substract(vecM0)).Multiply(0.5);
+    }
 
-	public void setVec_n(Vector vec_n) {
-		this.vec_n = vec_n;
-	}
-    
-    
-    
-    
+    public Vector getVec_n() {
+        return vec_n;
+    }
+
+    public void setVec_n(Vector vec_n) {
+        this.vec_n = vec_n;
+    }
+
 }

Modified: java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/Plane.java
 =============================================================================
--- java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/Plane.java	(original)
+++ java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/Plane.java	Wed Apr 27 12:23:44 2016
@@ -1,44 +1,40 @@
 /*
- * Supposed to calculate plane  equation for any 3 points not in one line
- * I will not check this, so please take care
- * the shape is Ax+By+Cy+D=0
- * Get the ABCD constants as array or whatever.
+ * Supposed to calculate plane equation for any 3 points not in one line I will not check this, so please take care the
+ * shape is Ax+By+Cy+D=0 Get the ABCD constants as array or whatever.
  */
 
 package org.hps.detector.ecal.geo2015.geoutils;
 
+public class Plane {
 
-public class Plane {
-    private double  c1=0.,c2=0.,c3=0.,c4=0.,c5=0.,c6=0.;
-    
-    //Plane full equation constants
-    private double  A,B,C,D;
+    private double c1 = 0., c2 = 0., c3 = 0., c4 = 0., c5 = 0., c6 = 0.;
+
+    // Plane full equation constants
+    private double A, B, C, D;
     private Vector normal = new Vector();
-    
-    //Plane as a ranges on XYZ axises
-    private double a=0., b=0., c=0.;
-   
-    
-    
-    //define plane by 3 points not in one line
-    public Plane(double [] P1,double [] P2,double [] P3){               
-        defConsts(P1, P2, P3); 
-        normal.SetXYZ(A,B,C);
+
+    // Plane as a ranges on XYZ axises
+    private double a = 0., b = 0., c = 0.;
+
+    // define plane by 3 points not in one line
+    public Plane(double[] P1, double[] P2, double[] P3) {
+        defConsts(P1, P2, P3);
+        normal.SetXYZ(A, B, C);
         this.Plane2GeoRanges();
     }
-    
+
     // define plane by constants Ax+By+Cz+D=0
-    public Plane(double A, double B, double C, double D){
+    public Plane(double A, double B, double C, double D) {
         this.A = A;
         this.B = B;
         this.C = C;
         this.D = D;
         normal.SetXYZ(A, B, C);
-        
+
         this.Plane2GeoRanges();
     }
-    
-    public void SetABCDcoeff(double AA, double BB, double CC, double DD){
+
+    public void SetABCDcoeff(double AA, double BB, double CC, double DD) {
         this.A = AA;
         this.B = BB;
         this.C = CC;
@@ -46,143 +42,131 @@
         normal.SetXYZ(A, B, C);
     }
 
-   public Vector getNormalUnitVector(){
-       double mod = normal.Module();
-       Vector uNorm = new Vector(normal.x/mod, normal.y/mod, normal.z/mod);
-       return uNorm;
-   }
-     
-    private void defConsts(double [] P1,double [] P2,double [] P3){
-        double x1 = P1[0], x2=P2[0], x3=P3[0];
-        double y1 = P1[1], y2=P2[1], y3=P3[1];
-        double z1 = P1[2], z2=P2[2], z3=P3[2];
-        
-         c1 = (x2-x1);
-         c2 = (y2-y1);
-         c3 = (z2-z1);
-         c4 = (x3-x1);
-         c5 = (y3-y1);
-         c6 = (z3-z1);   
-         
-         A = c2*c6 - c5*c3;
-         B=-(c1*c6 - c4*c3);
-         C = c1*c5 - c2*c4;
-         D = -(A*x1-(-B)*y1+C*z1);
-         //D = -x1*y2*z3 +x1*y3*z2 +x2*y1*z3 -x3*y1*z2 -x2*z1*y3 +x3*y2*z1; ///or this
+    public Vector getNormalUnitVector() {
+        double mod = normal.Module();
+        Vector uNorm = new Vector(normal.x / mod, normal.y / mod, normal.z / mod);
+        return uNorm;
     }
-    
-    
-    
-    public double [] getPlaneConsts(){
-        
-        double [] K = {A,B,C,D};
+
+    private void defConsts(double[] P1, double[] P2, double[] P3) {
+        double x1 = P1[0], x2 = P2[0], x3 = P3[0];
+        double y1 = P1[1], y2 = P2[1], y3 = P3[1];
+        double z1 = P1[2], z2 = P2[2], z3 = P3[2];
+
+        c1 = (x2 - x1);
+        c2 = (y2 - y1);
+        c3 = (z2 - z1);
+        c4 = (x3 - x1);
+        c5 = (y3 - y1);
+        c6 = (z3 - z1);
+
+        A = c2 * c6 - c5 * c3;
+        B = -(c1 * c6 - c4 * c3);
+        C = c1 * c5 - c2 * c4;
+        D = -(A * x1 - (-B) * y1 + C * z1);
+        // D = -x1*y2*z3 +x1*y3*z2 +x2*y1*z3 -x3*y1*z2 -x2*z1*y3 +x3*y2*z1; ///or this
+    }
+
+    public double[] getPlaneConsts() {
+
+        double[] K = {A, B, C, D};
         return K;
     }
-    
-    public double [] getNormalCoor(){
-      double [] K = {A,B,C};
-      return K;
+
+    public double[] getNormalCoor() {
+        double[] K = {A, B, C};
+        return K;
     }
-    
-    public Vector getNormal(){
-      return this.normal;
+
+    public Vector getNormal() {
+        return this.normal;
     }
-    
-    public double getAngle(double [] normal2){
 
-        double [] normal1 = this.getNormalCoor();
-        
-        double cosalpha = (normal1[0]*normal2[0]+normal1[1]*normal2[1]+normal1[2]*normal2[2])/
-                (Math.sqrt(normal1[0]*normal1[0]+normal1[1]*normal1[0]+normal1[2]*normal1[2])*
-                Math.sqrt(normal2[0]*normal2[0]+normal2[1]*normal2[0]+normal2[2]*normal2[2]));
-        
-   
+    public double getAngle(double[] normal2) {
+
+        double[] normal1 = this.getNormalCoor();
+
+        double cosalpha = (normal1[0] * normal2[0] + normal1[1] * normal2[1] + normal1[2] * normal2[2])
+                / (Math.sqrt(normal1[0] * normal1[0] + normal1[1] * normal1[0] + normal1[2] * normal1[2]) * Math
+                        .sqrt(normal2[0] * normal2[0] + normal2[1] * normal2[0] + normal2[2] * normal2[2]));
+
         return Math.acos(cosalpha);
     }
-    
-    public double getAngle(Plane pl2){
+
+    public double getAngle(Plane pl2) {
         Vector normal2 = pl2.getNormal();
-        double angle = this.normal.Angle(normal2);                
-   
-        return Math.PI/2 - angle;
+        double angle = this.normal.Angle(normal2);
+
+        return Math.PI / 2 - angle;
     }
-    
-    public double getEffAngle(Plane pl2){
+
+    public double getEffAngle(Plane pl2) {
         Vector normal2 = pl2.getNormal();
-        double angle = this.normal.Angle(normal2);                
-        if(angle>(Math.PI/2.0))
-          angle = Math.PI - angle ;
-        
+        double angle = this.normal.Angle(normal2);
+        if (angle > (Math.PI / 2.0))
+            angle = Math.PI - angle;
+
         return angle;
     }
-    
-    public double getK1(){
+
+    public double getK1() {
         return A;
     }
 
-    public double getK2(){
+    public double getK2() {
         return B;
     }
- 
-    public double getK3(){
+
+    public double getK3() {
         return C;
     }
-  
-    public double getK4(){
+
+    public double getK4() {
         return D;
     }
 
-    public double geta(){
+    public double geta() {
         return this.a;
     }
- 
-    public double getb(){
+
+    public double getb() {
         return this.b;
     }
-  
-    public double getc(){
+
+    public double getc() {
         return this.c;
     }
-    
-    public double [] getabc(){
-        double [] r = {a,b,c};
+
+    public double[] getabc() {
+        double[] r = {a, b, c};
         return r;
     }
-    
-    
-    
-    
-   /*
-    * if A || B || C = 0
-    * a = posInfinity
-    * b = posInfinity
-    * c = posInfinity
-    */ 
-   private void Plane2GeoRanges(){
-     
-       
-       
-       if(A!=0 && B!=0 && C!=0){
-       this.a = -this.D/this.A;
-       this.b = -this.D/this.B;
-       this.c = -this.D/this.C;
-       }
-       else
-       {
-           if(A==0)
-               this.a = Double.NEGATIVE_INFINITY;
-           if(B==0)
-               this.b = Double.NEGATIVE_INFINITY;
-           if(C==0)
-               this.c = Double.NEGATIVE_INFINITY;
-       }        
-   }
-   
-   public void Print(){
-    System.out.print(this.A+"x + " +"("+(this.B)+")"+"y + "+" ("+this.C+")"+"z + "+"("+this.D+")"+"= 0\n");
-   }
-   
-   public void PrintGeoRanges(){
-       System.out.print("X/("+this.a + ") + Y/("+this.b + ") + Z/("+this.c+") =1\n");
-   }
+
+    /*
+     * if A || B || C = 0 a = posInfinity b = posInfinity c = posInfinity
+     */
+    private void Plane2GeoRanges() {
+
+        if (A != 0 && B != 0 && C != 0) {
+            this.a = -this.D / this.A;
+            this.b = -this.D / this.B;
+            this.c = -this.D / this.C;
+        } else {
+            if (A == 0)
+                this.a = Double.NEGATIVE_INFINITY;
+            if (B == 0)
+                this.b = Double.NEGATIVE_INFINITY;
+            if (C == 0)
+                this.c = Double.NEGATIVE_INFINITY;
+        }
+    }
+
+    public void Print() {
+        System.out.print(this.A + "x + " + "(" + (this.B) + ")" + "y + " + " (" + this.C + ")" + "z + " + "(" + this.D
+                + ")" + "= 0\n");
+    }
+
+    public void PrintGeoRanges() {
+        System.out.print("X/(" + this.a + ") + Y/(" + this.b + ") + Z/(" + this.c + ") =1\n");
+    }
 }

Modified: java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/Vector.java
 =============================================================================
--- java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/Vector.java	(original)
+++ java/branches/HPSJAVA-409/detector-model/src/main/java/org/hps/detector/ecal/geo2015/geoutils/Vector.java	Wed Apr 27 12:23:44 2016
@@ -1,7 +1,6 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * To change this license header, choose License Headers in Project Properties. To change this template file, choose
+ * Tools | Templates and open the template in the editor.
  */
 
 package org.hps.detector.ecal.geo2015.geoutils;
@@ -9,155 +8,151 @@
 import org.hps.detector.ecal.geo2015.base.StatFunUtils;
 
 /**
- *Define Vector in a 3D coordinate system
- * operations and manipulations with the characteristics of the line
+ * Define Vector in a 3D coordinate system operations and manipulations with the characteristics of the line
+ * 
  * @author AS
  */
 public class Vector {
-    public double x=0, y=0, z=0;
-    private double [] vec;
-    
-    public Vector(){}
-    
-    public Vector(double [] array){
+
+    public double x = 0, y = 0, z = 0;
+    private double[] vec;
+
+    public Vector() {
+    }
+
+    public Vector(double[] array) {
         vec = array;
         this.x = array[0];
         this.y = array[1];
         this.z = array[2];
     }
-    
-    public Vector(double x, double y, double z){
-     this.x=x; this.y=y; this.z=z;
-     vec = new double[3];
-     vec[0] = x;
-     vec[1] = y;
-     vec[2] = z;
-     
+
+    public Vector(double x, double y, double z) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+        vec = new double[3];
+        vec[0] = x;
+        vec[1] = y;
+        vec[2] = z;
+
     }
-    
-    
-    public void SetX(double x){
+
+    public void SetX(double x) {
         this.x = x;
     }
-        
-    public void SetY(double y){
+
+    public void SetY(double y) {
         this.y = y;
-    }     
-     
-    public void SetZ(double z){
+    }
+
+    public void SetZ(double z) {
         this.z = z;
     }
-    
-    public void SetXYZ(double x, double y, double z){
+
+    public void SetXYZ(double x, double y, double z) {
         this.x = x;
         this.y = y;
         this.z = z;
     }
-    
-    
-    public boolean isUnitary(){
-        return (Double.compare(StatFunUtils.round(this.Module(),12), 1.0)==0);
+
+    public boolean isUnitary() {
+        return (Double.compare(StatFunUtils.round(this.Module(), 12), 1.0) == 0);
     }
-    
-    ///Vector Module
-    public double Module(){
-        return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);
+
+    // /Vector Module
+    public double Module() {
+        return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
     }
-    
-    public Vector Multiply(double k){
-                
+
+    public Vector Multiply(double k) {
+
         return (new Vector(k * this.x, k * this.y, k * this.z));
     }
-    
-    public Vector Add(Vector vec2){
-    
-        return (new Vector(this.x+vec2.x, this.y+vec2.y, this.z+vec2.z));
-    
+
+    public Vector Add(Vector vec2) {
+
+        return (new Vector(this.x + vec2.x, this.y + vec2.y, this.z + vec2.z));
+
     }
-    
-    public Vector getOpposite(){
+
+    public Vector getOpposite() {
         return (new Vector(-this.x, -this.y, -this.z));
     }
-    
-    public Vector Substract(Vector vec2){
-    
-        return (new Vector(this.x-vec2.x, this.y-vec2.y, this.z-vec2.z));
-    
+
+    public Vector Substract(Vector vec2) {
+
+        return (new Vector(this.x - vec2.x, this.y - vec2.y, this.z - vec2.z));
+
     }
-    
-    public Vector TranslateBy(Vector trvec){
-       // return this.Substract(trvec);
-    	return this.Add(trvec);
+
+    public Vector TranslateBy(Vector trvec) {
+        // return this.Substract(trvec);
+        return this.Add(trvec);
     }
-    
+
     /*
      * Rotation as Rz-alpha Ry-beta Rx-gamma
-     */     
-    public Vector RotateBy(double alpha, double betta, double gamma){
-    
+     */
+    public Vector RotateBy(double alpha, double betta, double gamma) {
+
         double cos_alpha = Math.cos(alpha);
         double sin_alpha = Math.sin(alpha);
-        
+
         double cos_betta = Math.cos(betta);
         double sin_betta = Math.sin(betta);
-        
+
         double cos_gamma = Math.cos(gamma);
         double sin_gamma = Math.sin(gamma);
-        
-        
-        double xx = this.x*cos_alpha*cos_betta+
-                    this.y*(-sin_alpha*cos_gamma + cos_alpha*sin_betta*sin_gamma)+
-                    this.z*(sin_alpha*sin_gamma+cos_alpha*sin_betta*sin_gamma);
-        
-        double yy = this.x*sin_alpha*cos_betta+
-                    this.y*(cos_alpha*cos_gamma+sin_alpha*sin_betta*sin_gamma)+
-                    this.z*(-cos_alpha*sin_gamma+sin_alpha*sin_betta*sin_gamma);
 
-        double zz = this.x*(-sin_betta)+
-                    this.y*(cos_betta*sin_gamma)+
-                    this.z*(cos_betta*cos_gamma);
-        
+        double xx = this.x * cos_alpha * cos_betta + this.y
+                * (-sin_alpha * cos_gamma + cos_alpha * sin_betta * sin_gamma) + this.z
+                * (sin_alpha * sin_gamma + cos_alpha * sin_betta * sin_gamma);
+
+        double yy = this.x * sin_alpha * cos_betta + this.y
+                * (cos_alpha * cos_gamma + sin_alpha * sin_betta * sin_gamma) + this.z
+                * (-cos_alpha * sin_gamma + sin_alpha * sin_betta * sin_gamma);
+
+        double zz = this.x * (-sin_betta) + this.y * (cos_betta * sin_gamma) + this.z * (cos_betta * cos_gamma);
+
         return (new Vector(xx, yy, zz));
     }
-    
-    
-    //Scaliar multiplication of vectors
-    public double ScaliarM(Vector vec2){
-        return this.x*vec2.x+this.y*vec2.y+this.z*vec2.z;
+
+    // Scaliar multiplication of vectors
+    public double ScaliarM(Vector vec2) {
+        return this.x * vec2.x + this.y * vec2.y + this.z * vec2.z;
     }
-    
-    //angle between vectors
-    public double Angle(Vector vec2){
-//    System.out.print("Scaliar= "+this.ScaliarM(vec2) +" modN1 = "+this.Module()+"  modN2 = "+vec2.Module()+"\n");
-        //   System.out.print(this.ScaliarM(vec2)/(this.Module()*vec2.Module())+ "\n");
-//    System.out.println(Math.acos(this.ScaliarM(vec2)/(this.Module()*vec2.Module())));
+
+    // angle between vectors
+    public double Angle(Vector vec2) {
+        // System.out.print("Scaliar= "+this.ScaliarM(vec2) +" modN1 = "+this.Module()+"  modN2 = "+vec2.Module()+"\n");
+        // System.out.print(this.ScaliarM(vec2)/(this.Module()*vec2.Module())+ "\n");
+        // System.out.println(Math.acos(this.ScaliarM(vec2)/(this.Module()*vec2.Module())));
         double cosAlpha = this.ScaliarM(vec2) / (this.Module() * vec2.Module());
-        
-        if (Double.compare(StatFunUtils.round(cosAlpha,12),1.0)==0) {
+
+        if (Double.compare(StatFunUtils.round(cosAlpha, 12), 1.0) == 0) {
             cosAlpha = 1.0;
-        }        
-        else if (Double.compare(StatFunUtils.round(cosAlpha,12),-1.0)==0) {
+        } else if (Double.compare(StatFunUtils.round(cosAlpha, 12), -1.0) == 0) {
             cosAlpha = -1.0;
         }
 
         return Math.acos(cosAlpha);
     }
-    
-    public double [] getVector(){        
+
+    public double[] getVector() {
         return this.vec;
     }
-    
-    public Vector getUnitVector(){    
-        return  new Vector(this.x/this.Module(), this.y/this.Module(), this.z/this.Module());    
+
+    public Vector getUnitVector() {
+        return new Vector(this.x / this.Module(), this.y / this.Module(), this.z / this.Module());
     }
-    
-    public Vector getCenter(){
-        
-        return (this.Multiply(0.5));        
+
+    public Vector getCenter() {
+
+        return (this.Multiply(0.5));
     }
-    
-    
-    public void Print(){
-        System.out.println("("+this.x+", "+this.y+", "+this.z+")");    
+
+    public void Print() {
+        System.out.println("(" + this.x + ", " + this.y + ", " + this.z + ")");
     }
 }

Modified: java/branches/HPSJAVA-409/detector-model/src/main/java/org/lcsim/detector/converter/compact/HPSEcal4Converter.java
 =============================================================================
--- java/branches/HPSJAVA-409/detector-model/src/main/java/org/lcsim/detector/converter/compact/HPSEcal4Converter.java	(original)
+++ java/branches/HPSJAVA-409/detector-model/src/main/java/org/lcsim/detector/converter/compact/HPSEcal4Converter.java	Wed Apr 27 12:23:44 2016
@@ -1,5 +1,4 @@
 package org.lcsim.detector.converter.compact;
-
 
 import java.util.Map;
 import java.util.logging.Logger;
@@ -34,192 +33,196 @@
 
 public class HPSEcal4Converter extends AbstractSubdetectorConverter {
 
-	private static Logger LOGGER = Logger.getLogger(HPSEcal4Converter.class.getPackage().getName());
-
-	// Margin for mother volume.
-	// private static final double margin = 1.1;
-
-	private IIdentifierDictionary dict;
-	private IIdentifierHelper helper;
-
-	//private List<CrystalRange> ranges = new ArrayList<CrystalRange>();
-
-	@Override
-	public void convert(final Subdetector subdet, final Detector detector) {
-
-		LOGGER.info("converting subdetector " + subdet.getName());
-
-		helper = subdet.getDetectorElement().getIdentifierHelper();
-		dict = helper.getIdentifierDictionary();
-
-		// Crystal dimensions.
-		final Element dimensions = subdet.getNode().getChild("dimensions");
-
-		double dx1, dx2, dy1, dy2, dz;
-		Element layout;
-		int nx, ny;
-		double dface;
-		
-		//initial definitions for translation and rotation parameters
-		double tr_top[] = { -100, -100, -100 };
-		double tr_bot[] = { -100, -100, -100 };
-		double rot_top[] = { -100, -100, -100 };
-		double rot_bot[] = { -100, -100, -100 };
-
-		try {
-			dx1 = dimensions.getAttribute("x1").getDoubleValue();
-			dx2 = dimensions.getAttribute("x2").getDoubleValue();
-			dy1 = dimensions.getAttribute("y1").getDoubleValue();
-			dy2 = dimensions.getAttribute("y2").getDoubleValue();
-			dz = dimensions.getAttribute("z").getDoubleValue();
-
-			Element tra = subdet.getNode().getChild("translations");
-
-			tr_top[0] = tra.getAttribute("top_tr_x").getDoubleValue();
-			tr_top[1] = tra.getAttribute("top_tr_y").getDoubleValue();
-			tr_top[2] = tra.getAttribute("top_tr_z").getDoubleValue();
-
-			tr_bot[0] = tra.getAttribute("bot_tr_x").getDoubleValue();
-			tr_bot[1] = tra.getAttribute("bot_tr_y").getDoubleValue();
-			tr_bot[2] = tra.getAttribute("bot_tr_z").getDoubleValue();
-
-			Element rota = subdet.getNode().getChild("rotations");
-
-			rot_top[0] = rota.getAttribute("top_rot_alpha").getDoubleValue();
-			rot_top[1] = rota.getAttribute("top_rot_beta").getDoubleValue();
-			rot_top[2] = rota.getAttribute("top_rot_gamma").getDoubleValue();
-
-			rot_bot[0] = rota.getAttribute("bot_rot_alpha").getDoubleValue();
-			rot_bot[1] = rota.getAttribute("bot_rot_beta").getDoubleValue();
-			rot_bot[2] = rota.getAttribute("bot_rot_gamma").getDoubleValue();
-			 
-			layout = subdet.getNode().getChild("layout");
-			nx = layout.getAttribute("nx").getIntValue();
-			ny = layout.getAttribute("ny").getIntValue();
-			dface = layout.getAttribute("dface").getDoubleValue();
-
-		} catch (final DataConversionException e) {
-			throw new RuntimeException("Error converting HPSEcal4 from XML.", e);
-		}
-
-		// Crystal material.
-		final Element mat = subdet.getNode().getChild("material");
-		final String materialName = mat.getAttributeValue("name");
-
-		// Setup crystal logical volume.
-		final Trd crystalTrap = new Trd("crystal_trap", dx1, dx2, dy1, dy2, dz);
-		final ILogicalVolume crystalLogVol = new LogicalVolume("crystal_volume", crystalTrap, MaterialStore.getInstance().get(materialName));
-
-		//
-		// Translate and rotate the modules by the rotation and translation vectors
-		// defined  in compact.xml file, or by default?
-		// it's not really clear what you dear hps user want
-		//
-		Transformations trans_top = new Transformations("top", tr_top, rot_top);
-		Map<String, Crystal> topMap = trans_top.getCrystalMap();
-		Transformations trans_bot = new Transformations("bottom", tr_bot, rot_bot);
-		Map<String, Crystal> botMap = trans_bot.getCrystalMap();
-		System.err.println("Number of map content   " + botMap.size());
-		System.err.println("Number of map content   " + topMap.size());
-
-		// Base name for volume.
-		final String baseName = subdet.getName() + "_crystal";
-
-		// World volume.
-		final ILogicalVolume mom = detector.getWorldVolume().getLogicalVolume();
-		//crystal counter
-		int crystaln = 1; 
-		
-		//loop over layers
-		for (int iy = -5; iy <= 5; iy++) {
-			if (iy == 0)
-				continue;
-			
-			//loop over columns 
-			for (int ix = -23; ix <= 23; ix++) {
-				if (ix == 0) {
-					continue;
-				}
-				
-				//z axis rotation parameter of the whole module
-				double zrot_cry = rot_bot[0];
-				
-				
-				Crystal crystal = botMap.get(String.format("c%d:l%d", ix, iy));
-
-				if (iy > 0) {
-					crystal = topMap.get(String.format("c%d:l%d", ix, iy));
-					//z axis rotation parameter of the whole module
-					zrot_cry = rot_top[0];
-				}
-
-				if (crystal == null)
-					if ((iy == -1 && ix > -11 && ix < -1) || (iy == 1 && ix > -11 && ix < -1))
-						continue;
-					else
-						System.err.println(iy + " " + ix + " crystal is null, the map is screwed, the compiler really feels sorry for you.");
-
-				if (crystal.getCrystalG4Pos() == null)
-					System.err.print("g4pos of crystal is null, the map is screwed, sorry\n");
-
-				double[] centerxyz = { 0, 0, 0 };
-				double[] thetaxyz = { 0, 0, 0 };
-				if (crystal != null) {
-					centerxyz = crystal.getCrystalG4Pos().getCenterArr();
-					thetaxyz = crystal.getCrystalG4Pos().getTaitBryanAngles();
-				}
-
-				final ITranslation3D iposBot = new Translation3D(centerxyz[0], centerxyz[1], centerxyz[2]);
-				final IRotation3D irotBot = new RotationGeant(thetaxyz[0], thetaxyz[1], thetaxyz[2]-zrot_cry); // thetaxyz[2]-zrot_cry= the compound rotation for the Psie
-				//final IRotation3D irotBot = new RotationGeant(thetaxyz[0], thetaxyz[1], thetaxyz[2]+zrot_cry); // thetaxyz[2]+zrot_cry= the compound rotation for the Psie
-				
-				// Place the crystal.
-				final IPhysicalVolume CrystalPlacement = new PhysicalVolume(new Transform3D(iposBot, irotBot), baseName + crystaln, crystalLogVol, mom, crystaln);
-				this.createDetectorElement(detector, subdet, CrystalPlacement, ix, iy);
-				crystaln++;
-				
-				
-			}
-		}
-		System.err.println("In HPSEcal4Converter crystal in top module:" + topMap.size()+"   crystals in bottom module:  "+ botMap.size());
-	}
-
-	/**
-	 * Create a DetectorElement for an ECal crystal.
-	 *
-	 * @param detector
-	 *            The full detector.
-	 * @param subdet
-	 *            The sub detector.
-	 * @param crystal
-	 *            The crystal physical volume.
-	 * @param ix
-	 *            The value of the ix field.
-	 * @param iy
-	 *            The value of the iy field.
-	 */
-	private final void createDetectorElement(final Detector detector, final Subdetector subdet,
-			final IPhysicalVolume crystal, final int ix, final int iy) {
-		final String path = "/" + crystal.getName();
-		final IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields());
-		expId.setValue(dict.getFieldIndex("system"), subdet.getSystemID());
-		expId.setValue(dict.getFieldIndex("ix"), ix);
-		expId.setValue(dict.getFieldIndex("iy"), iy);
-		final IIdentifier id = helper.pack(expId);
-		new EcalCrystal(subdet.getName() + "_crystal" + crystal.getCopyNumber(), subdet.getDetectorElement(), path, id);
-	}
-
-	@Override
-	public Class getSubdetectorType() {
-		return HPSEcal4.class;
-	}
-
-	@Override
-	public IDetectorElement makeSubdetectorDetectorElement(final Detector detector, final Subdetector subdetector) {
-		LOGGER.info("creating detector element for subdetector " + subdetector.getName());
-		final IDetectorElement subdetectorDE = new HPSEcalDetectorElement(subdetector.getName(),
-				detector.getDetectorElement());
-		subdetector.setDetectorElement(subdetectorDE);
-		return subdetectorDE;
-	}
+    private static Logger LOGGER = Logger.getLogger(HPSEcal4Converter.class.getPackage().getName());
+
+    // Margin for mother volume.
+    // private static final double margin = 1.1;
+
+    private IIdentifierDictionary dict;
+    private IIdentifierHelper helper;
+
+    // private List<CrystalRange> ranges = new ArrayList<CrystalRange>();
+
+    @Override
+    public void convert(final Subdetector subdet, final Detector detector) {
+
+        LOGGER.info("converting subdetector " + subdet.getName());
+
+        helper = subdet.getDetectorElement().getIdentifierHelper();
+        dict = helper.getIdentifierDictionary();
+
+        // Crystal dimensions.
+        final Element dimensions = subdet.getNode().getChild("dimensions");
+
+        double dx1, dx2, dy1, dy2, dz;
+        Element layout;
+        int nx, ny;
+        double dface;
+
+        // initial definitions for translation and rotation parameters
+        double tr_top[] = {-100, -100, -100};
+        double tr_bot[] = {-100, -100, -100};
+        double rot_top[] = {-100, -100, -100};
+        double rot_bot[] = {-100, -100, -100};
+
+        try {
+            dx1 = dimensions.getAttribute("x1").getDoubleValue();
+            dx2 = dimensions.getAttribute("x2").getDoubleValue();
+            dy1 = dimensions.getAttribute("y1").getDoubleValue();
+            dy2 = dimensions.getAttribute("y2").getDoubleValue();
+            dz = dimensions.getAttribute("z").getDoubleValue();
+
+            Element tra = subdet.getNode().getChild("translations");
+
+            tr_top[0] = tra.getAttribute("top_tr_x").getDoubleValue();
+            tr_top[1] = tra.getAttribute("top_tr_y").getDoubleValue();
+            tr_top[2] = tra.getAttribute("top_tr_z").getDoubleValue();
+
+            tr_bot[0] = tra.getAttribute("bot_tr_x").getDoubleValue();
+            tr_bot[1] = tra.getAttribute("bot_tr_y").getDoubleValue();
+            tr_bot[2] = tra.getAttribute("bot_tr_z").getDoubleValue();
+
+            Element rota = subdet.getNode().getChild("rotations");
+
+            rot_top[0] = rota.getAttribute("top_rot_alpha").getDoubleValue();
+            rot_top[1] = rota.getAttribute("top_rot_beta").getDoubleValue();
+            rot_top[2] = rota.getAttribute("top_rot_gamma").getDoubleValue();
+
+            rot_bot[0] = rota.getAttribute("bot_rot_alpha").getDoubleValue();
+            rot_bot[1] = rota.getAttribute("bot_rot_beta").getDoubleValue();
+            rot_bot[2] = rota.getAttribute("bot_rot_gamma").getDoubleValue();
+
+            layout = subdet.getNode().getChild("layout");
+            nx = layout.getAttribute("nx").getIntValue();
+            ny = layout.getAttribute("ny").getIntValue();
+            dface = layout.getAttribute("dface").getDoubleValue();
+
+        } catch (final DataConversionException e) {
+            throw new RuntimeException("Error converting HPSEcal4 from XML.", e);
+        }
+
+        // Crystal material.
+        final Element mat = subdet.getNode().getChild("material");
+        final String materialName = mat.getAttributeValue("name");
+
+        // Setup crystal logical volume.
+        final Trd crystalTrap = new Trd("crystal_trap", dx1, dx2, dy1, dy2, dz);
+        final ILogicalVolume crystalLogVol = new LogicalVolume("crystal_volume", crystalTrap, MaterialStore
+                .getInstance().get(materialName));
+
+        //
+        // Translate and rotate the modules by the rotation and translation vectors
+        // defined in compact.xml file, or by default?
+        // it's not really clear what you dear hps user want
+        //
+        Transformations trans_top = new Transformations("top", tr_top, rot_top);
+        Map<String, Crystal> topMap = trans_top.getCrystalMap();
+        Transformations trans_bot = new Transformations("bottom", tr_bot, rot_bot);
+        Map<String, Crystal> botMap = trans_bot.getCrystalMap();
+        System.err.println("Number of map content   " + botMap.size());
+        System.err.println("Number of map content   " + topMap.size());
+
+        // Base name for volume.
+        final String baseName = subdet.getName() + "_crystal";
+
+        // World volume.
+        final ILogicalVolume mom = detector.getWorldVolume().getLogicalVolume();
+        // crystal counter
+        int crystaln = 1;
+
+        // loop over layers
+        for (int iy = -5; iy <= 5; iy++) {
+            if (iy == 0)
+                continue;
+
+            // loop over columns
+            for (int ix = -23; ix <= 23; ix++) {
+                if (ix == 0) {
+                    continue;
+                }
+
+                // z axis rotation parameter of the whole module
+                double zrot_cry = rot_bot[0];
+
+                Crystal crystal = botMap.get(String.format("c%d:l%d", ix, iy));
+
+                if (iy > 0) {
+                    crystal = topMap.get(String.format("c%d:l%d", ix, iy));
+                    // z axis rotation parameter of the whole module
+                    zrot_cry = rot_top[0];
+                }
+
+                if (crystal == null)
+                    if ((iy == -1 && ix > -11 && ix < -1) || (iy == 1 && ix > -11 && ix < -1))
+                        continue;
+                    else
+                        System.err.println(iy + " " + ix
+                                + " crystal is null, the map is screwed, the compiler really feels sorry for you.");
+
+                if (crystal.getCrystalG4Pos() == null)
+                    System.err.print("g4pos of crystal is null, the map is screwed, sorry\n");
+
+                double[] centerxyz = {0, 0, 0};
+                double[] thetaxyz = {0, 0, 0};
+                if (crystal != null) {
+                    centerxyz = crystal.getCrystalG4Pos().getCenterArr();
+                    thetaxyz = crystal.getCrystalG4Pos().getTaitBryanAngles();
+                }
+
+                final ITranslation3D iposBot = new Translation3D(centerxyz[0], centerxyz[1], centerxyz[2]);
+                final IRotation3D irotBot = new RotationGeant(thetaxyz[0], thetaxyz[1], thetaxyz[2] - zrot_cry); // thetaxyz[2]-zrot_cry=
+                                                                                                                 // the
+                                                                                                                 // compound
+                                                                                                                 // rotation
+                                                                                                                 // for
+                                                                                                                 // the
+                                                                                                                 // Psie
+                // final IRotation3D irotBot = new RotationGeant(thetaxyz[0], thetaxyz[1], thetaxyz[2]+zrot_cry); //
+                // thetaxyz[2]+zrot_cry= the compound rotation for the Psie
+
+                // Place the crystal.
+                final IPhysicalVolume CrystalPlacement = new PhysicalVolume(new Transform3D(iposBot, irotBot), baseName
+                        + crystaln, crystalLogVol, mom, crystaln);
+                this.createDetectorElement(detector, subdet, CrystalPlacement, ix, iy);
+                crystaln++;
+
+            }
+        }
+        System.err.println("In HPSEcal4Converter crystal in top module:" + topMap.size()
+                + "   crystals in bottom module:  " + botMap.size());
+    }
+
+    /**
+     * Create a DetectorElement for an ECal crystal.
+     *
+     * @param detector The full detector.
+     * @param subdet The sub detector.
+     * @param crystal The crystal physical volume.
+     * @param ix The value of the ix field.
+     * @param iy The value of the iy field.
+     */
+    private final void createDetectorElement(final Detector detector, final Subdetector subdet,
+            final IPhysicalVolume crystal, final int ix, final int iy) {
+        final String path = "/" + crystal.getName();
+        final IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields());
+        expId.setValue(dict.getFieldIndex("system"), subdet.getSystemID());
+        expId.setValue(dict.getFieldIndex("ix"), ix);
+        expId.setValue(dict.getFieldIndex("iy"), iy);
+        final IIdentifier id = helper.pack(expId);
+        new EcalCrystal(subdet.getName() + "_crystal" + crystal.getCopyNumber(), subdet.getDetectorElement(), path, id);
+    }
+
+    @Override
+    public Class getSubdetectorType() {
+        return HPSEcal4.class;
+    }
+
+    @Override
+    public IDetectorElement makeSubdetectorDetectorElement(final Detector detector, final Subdetector subdetector) {
+        LOGGER.info("creating detector element for subdetector " + subdetector.getName());
+        final IDetectorElement subdetectorDE = new HPSEcalDetectorElement(subdetector.getName(),
+                detector.getDetectorElement());
+        subdetector.setDetectorElement(subdetectorDE);
+        return subdetectorDE;
+    }
 }

Modified: java/branches/HPSJAVA-409/detector-model/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSEcal4.java
 =============================================================================
--- java/branches/HPSJAVA-409/detector-model/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSEcal4.java	(original)
+++ java/branches/HPSJAVA-409/detector-model/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSEcal4.java	Wed Apr 27 12:23:44 2016
@@ -18,179 +18,177 @@
 
 public class HPSEcal4 extends LCDDSubdetector {
 
-	HPSEcal4(Element node) throws JDOMException {
-		super(node);
-	}
+    HPSEcal4(Element node) throws JDOMException {
+        super(node);
+    }
 
-	void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException {
-		if (sens == null)
-			throw new RuntimeException("SensitiveDetector parameter points to null.");
+    void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException {
+        if (sens == null)
+            throw new RuntimeException("SensitiveDetector parameter points to null.");
 
-		// Crystal dimensions.
-		Element dimensions = node.getChild("dimensions");
-		double dx1 = dimensions.getAttribute("x1").getDoubleValue();
-		double dx2 = dimensions.getAttribute("x2").getDoubleValue();
-		double dy1 = dimensions.getAttribute("y1").getDoubleValue();
-		double dy2 = dimensions.getAttribute("y2").getDoubleValue();
-		double dz = dimensions.getAttribute("z").getDoubleValue();
+        // Crystal dimensions.
+        Element dimensions = node.getChild("dimensions");
+        double dx1 = dimensions.getAttribute("x1").getDoubleValue();
+        double dx2 = dimensions.getAttribute("x2").getDoubleValue();
+        double dy1 = dimensions.getAttribute("y1").getDoubleValue();
+        double dy2 = dimensions.getAttribute("y2").getDoubleValue();
+        double dz = dimensions.getAttribute("z").getDoubleValue();
 
-		int system = this.getSystemID();
+        int system = this.getSystemID();
 
-		// Crystal material.
-		Element mat = node.getChild("material");
-		String materialName = mat.getAttributeValue("name");
+        // Crystal material.
+        Element mat = node.getChild("material");
+        String materialName = mat.getAttributeValue("name");
 
-		Element tra = node.getChild("translations");
-		double tr_top[] = {-100,-100,-100};
-		tr_top[0] = tra.getAttribute("top_tr_x").getDoubleValue();
-		tr_top[1] = tra.getAttribute("top_tr_y").getDoubleValue();
-		tr_top[2] = tra.getAttribute("top_tr_z").getDoubleValue();
-		double tr_bot[] = {-100,-100,-100};
-		tr_bot[0] = tra.getAttribute("bot_tr_x").getDoubleValue();
-		tr_bot[1] = tra.getAttribute("bot_tr_y").getDoubleValue();
-		tr_bot[2] = tra.getAttribute("bot_tr_z").getDoubleValue();
-		
-		Element rota = node.getChild("rotations");
-		double rot_top[] = {-100,-100,-100};
-		rot_top[0] = rota.getAttribute("top_rot_alpha").getDoubleValue();
-		rot_top[1] = rota.getAttribute("top_rot_beta").getDoubleValue();
-		rot_top[2] = rota.getAttribute("top_rot_gamma").getDoubleValue();
-		double rot_bot[] = {-100,-100,-100};
-		rot_bot[0] = rota.getAttribute("bot_rot_alpha").getDoubleValue();
-		rot_bot[1] = rota.getAttribute("bot_rot_beta").getDoubleValue();
-		rot_bot[2] = rota.getAttribute("bot_rot_gamma").getDoubleValue();
-		
-		// Layout parameters.
-		Element layout = node.getChild("layout");
-		double beamgap = 0;
-		if (layout.getAttribute("beamgap") != null) {
-			beamgap = layout.getAttribute("beamgap").getDoubleValue();
-		} else {
-			if (layout.getAttribute("beamgapTop") == null || layout.getAttribute("beamgapBottom") == null) {
-				throw new RuntimeException(
-						"Missing beamgap parameter in layout element, and beamgapTop or beamgapBottom was not provided.");
-			}
-		}
-		
-		int nx = layout.getAttribute("nx").getIntValue();
-		int ny = layout.getAttribute("ny").getIntValue();
-		double dface = layout.getAttribute("dface").getDoubleValue();
+        Element tra = node.getChild("translations");
+        double tr_top[] = {-100, -100, -100};
+        tr_top[0] = tra.getAttribute("top_tr_x").getDoubleValue();
+        tr_top[1] = tra.getAttribute("top_tr_y").getDoubleValue();
+        tr_top[2] = tra.getAttribute("top_tr_z").getDoubleValue();
+        double tr_bot[] = {-100, -100, -100};
+        tr_bot[0] = tra.getAttribute("bot_tr_x").getDoubleValue();
+        tr_bot[1] = tra.getAttribute("bot_tr_y").getDoubleValue();
+        tr_bot[2] = tra.getAttribute("bot_tr_z").getDoubleValue();
 
-		
-		// Setup crystal logical volume.
-		//dy1=dx1=1.00; dy2=dx2=20.00; dz=50;
-		Trapezoid crystalTrap = new Trapezoid("crystal_trap", dx1, dx2, dy1, dy2, dz);
-		Volume crystalLogVol = new Volume("crystal_volume", crystalTrap, lcdd.getMaterial(materialName));
-		crystalLogVol.setSensitiveDetector(sens);
+        Element rota = node.getChild("rotations");
+        double rot_top[] = {-100, -100, -100};
+        rot_top[0] = rota.getAttribute("top_rot_alpha").getDoubleValue();
+        rot_top[1] = rota.getAttribute("top_rot_beta").getDoubleValue();
+        rot_top[2] = rota.getAttribute("top_rot_gamma").getDoubleValue();
+        double rot_bot[] = {-100, -100, -100};
+        rot_bot[0] = rota.getAttribute("bot_rot_alpha").getDoubleValue();
+        rot_bot[1] = rota.getAttribute("bot_rot_beta").getDoubleValue();
+        rot_bot[2] = rota.getAttribute("bot_rot_gamma").getDoubleValue();
 
-		// Set vis attributes on crystal log vol.
-		setVisAttributes(lcdd, this.getNode(), crystalLogVol);
+        // Layout parameters.
+        Element layout = node.getChild("layout");
+        double beamgap = 0;
+        if (layout.getAttribute("beamgap") != null) {
+            beamgap = layout.getAttribute("beamgap").getDoubleValue();
+        } else {
+            if (layout.getAttribute("beamgapTop") == null || layout.getAttribute("beamgapBottom") == null) {
+                throw new RuntimeException(
+                        "Missing beamgap parameter in layout element, and beamgapTop or beamgapBottom was not provided.");
+            }
+        }
 
-		// Add shape and log vol to lcdd.
-		lcdd.add(crystalTrap);
-		lcdd.add(crystalLogVol);
+        int nx = layout.getAttribute("nx").getIntValue();
+        int ny = layout.getAttribute("ny").getIntValue();
+        double dface = layout.getAttribute("dface").getDoubleValue();
 
-		// Place crystals in world volume.
-		Volume world = lcdd.pickMotherVolume(this);
+        // Setup crystal logical volume.
+        // dy1=dx1=1.00; dy2=dx2=20.00; dz=50;
+        Trapezoid crystalTrap = new Trapezoid("crystal_trap", dx1, dx2, dy1, dy2, dz);
+        Volume crystalLogVol = new Volume("crystal_volume", crystalTrap, lcdd.getMaterial(materialName));
+        crystalLogVol.setSensitiveDetector(sens);
 
-		//
-		// defines the constant from compact.xml, may be
-		//
+        // Set vis attributes on crystal log vol.
+        setVisAttributes(lcdd, this.getNode(), crystalLogVol);
 
-		Define define = lcdd.getDefine();
+        // Add shape and log vol to lcdd.
+        lcdd.add(crystalTrap);
+        lcdd.add(crystalLogVol);
 
-		//
-		// Defining the translation and the rotation of top and bottom based on
-		// Survey Aug2015
-		//
-		
-		double[] top_tr = { 0, 0, 0}; 	
-		double[] top_rot =  { 0, 0, 0}; 
-		double[] bot_tr =  { 0, 0, 0}; 
-		double[] bot_rot =  { 0, 0, 0}; 
-		
-		
-		/*double[] top_tr = { -0.710000000000008, 2.7249999999999943, 4.9375 };																				
-		double[] top_rot = { 6.496421277200071E-4, 0.0, -4.688234741242468E-4 };
-		double[] bot_tr =  { -0.4049999999999727, -0.9124999999999659, 2.6224999999999454 }; 
-		double[] bot_rot = { 5.150274940439736E-4, 0.0, 0.0013469727279283583 };*/
-		
-		/*	double[] top_tr = {100, 0, 0 };																				
-		double[] top_rot = { Math.toRadians(-20),0,0};
-		double[] bot_tr =  { 0,0,0 }; 
-		double[] bot_rot = { 0,0,0 };
-		*/
-		
-		//I had my reasons to do so, will change in the end
-		top_rot =rot_top;
-		top_tr = tr_top;
-		bot_rot =rot_bot;
-		bot_tr = tr_bot;
-		
-		Transformations trans_top = new Transformations("top", top_tr, top_rot);
-		Map<String, Crystal> topMap = trans_top.getCrystalMap();
-		Transformations trans_bot = new Transformations("bottom", bot_tr, bot_rot);
-		Map<String, Crystal> botMap = trans_bot.getCrystalMap();
-		System.err.println("Number of map content   " + botMap.size());
-		System.err.println("Number of map content   " + topMap.size());
-		
-		for (int iy = -5; iy <= 5; iy++) {
-			if(iy==0)
-				continue;
-			for (int ix = -23; ix <= 23; ix++) {
-				if (ix == 0) {
-					continue;
-				}
-				
-				//z axis rotation parameter of the whole module
-				double zrot_cry = bot_rot[0];
-				String baseName = "crystal" + ix + "-" + iy;
+        // Place crystals in world volume.
+        Volume world = lcdd.pickMotherVolume(this);
 
-				Crystal crystal = botMap.get(String.format("c%d:l%d", ix, iy));
+        //
+        // defines the constant from compact.xml, may be
+        //
 
-				if (iy > 0){
-					crystal = topMap.get(String.format("c%d:l%d", ix, iy));
-					//z axis rotation parameter of the whole module
-					zrot_cry = top_rot[0];
-				}
-				
-				if (crystal == null)
-					if((iy==-1 && ix>-11 && ix<-1) || (iy==1 && ix>-11 && ix<-1)  )
-						continue;
-					else
-						System.err.println(iy+" "+ix+" crystal is null, the map is screwed");
-				
-				
-				if (crystal.getCrystalG4Pos() == null)
-					System.err.print("g4pos of crystal is null, the map is screwed, sorry\n");
+        Define define = lcdd.getDefine();
 
-				double[] centerxyz = { 0, 0, 0 };
-				double[] thetaxyz = { 0, 0, 0 };
-				if (crystal != null) {
-					centerxyz = crystal.getCrystalG4Pos().getCenterArr();
-					thetaxyz = crystal.getCrystalG4Pos().getTaitBryanAngles();
-				}
+        //
+        // Defining the translation and the rotation of top and bottom based on
+        // Survey Aug2015
+        //
 
-				// Transform of crystal.
-				Position ipos = new Position(baseName + "_pos", centerxyz[0], centerxyz[1], centerxyz[2]);				
-				Rotation irot = new Rotation(baseName + "_rot", thetaxyz[0], thetaxyz[1], thetaxyz[2]-zrot_cry);
-				define.addPosition(ipos);
-				define.addRotation(irot);
+        double[] top_tr = {0, 0, 0};
+        double[] top_rot = {0, 0, 0};
+        double[] bot_tr = {0, 0, 0};
+        double[] bot_rot = {0, 0, 0};
 
-				// Place the crystal.
-				PhysVol CrystalPlacementBot = new PhysVol(crystalLogVol, world, ipos, irot);
-				// Add volume IDs.
-				CrystalPlacementBot.addPhysVolID("system", system);
-				CrystalPlacementBot.addPhysVolID("ix", ix);
-				CrystalPlacementBot.addPhysVolID("iy", iy);
+        /*
+         * double[] top_tr = { -0.710000000000008, 2.7249999999999943, 4.9375 }; double[] top_rot = {
+         * 6.496421277200071E-4, 0.0, -4.688234741242468E-4 }; double[] bot_tr = { -0.4049999999999727,
+         * -0.9124999999999659, 2.6224999999999454 }; double[] bot_rot = { 5.150274940439736E-4, 0.0,
+         * 0.0013469727279283583 };
+         */
 
-			}
+        /*
+         * double[] top_tr = {100, 0, 0 }; double[] top_rot = { Math.toRadians(-20),0,0}; double[] bot_tr = { 0,0,0 };
+         * double[] bot_rot = { 0,0,0 };
+         */
 
-		}
+        // I had my reasons to do so, will change in the end
+        top_rot = rot_top;
+        top_tr = tr_top;
+        bot_rot = rot_bot;
+        bot_tr = tr_bot;
 
-	}
+        Transformations trans_top = new Transformations("top", top_tr, top_rot);
+        Map<String, Crystal> topMap = trans_top.getCrystalMap();
+        Transformations trans_bot = new Transformations("bottom", bot_tr, bot_rot);
+        Map<String, Crystal> botMap = trans_bot.getCrystalMap();
+        System.err.println("Number of map content   " + botMap.size());
+        System.err.println("Number of map content   " + topMap.size());
 
-	public boolean isCalorimeter() {
-		return true;
-	}
+        for (int iy = -5; iy <= 5; iy++) {
+            if (iy == 0)
+                continue;
+            for (int ix = -23; ix <= 23; ix++) {
+                if (ix == 0) {
+                    continue;
+                }
+
+                // z axis rotation parameter of the whole module
+                double zrot_cry = bot_rot[0];
+                String baseName = "crystal" + ix + "-" + iy;
+
+                Crystal crystal = botMap.get(String.format("c%d:l%d", ix, iy));
+
+                if (iy > 0) {
+                    crystal = topMap.get(String.format("c%d:l%d", ix, iy));
+                    // z axis rotation parameter of the whole module
+                    zrot_cry = top_rot[0];
+                }
+
+                if (crystal == null)
+                    if ((iy == -1 && ix > -11 && ix < -1) || (iy == 1 && ix > -11 && ix < -1))
+                        continue;
+                    else
+                        System.err.println(iy + " " + ix + " crystal is null, the map is screwed");
+
+                if (crystal.getCrystalG4Pos() == null)
+                    System.err.print("g4pos of crystal is null, the map is screwed, sorry\n");
+
+                double[] centerxyz = {0, 0, 0};
+                double[] thetaxyz = {0, 0, 0};
+                if (crystal != null) {
+                    centerxyz = crystal.getCrystalG4Pos().getCenterArr();
+                    thetaxyz = crystal.getCrystalG4Pos().getTaitBryanAngles();
+                }
+
+                // Transform of crystal.
+                Position ipos = new Position(baseName + "_pos", centerxyz[0], centerxyz[1], centerxyz[2]);
+                Rotation irot = new Rotation(baseName + "_rot", thetaxyz[0], thetaxyz[1], thetaxyz[2] - zrot_cry);
+                define.addPosition(ipos);
+                define.addRotation(irot);
+
+                // Place the crystal.
+                PhysVol CrystalPlacementBot = new PhysVol(crystalLogVol, world, ipos, irot);
+                // Add volume IDs.
+                CrystalPlacementBot.addPhysVolID("system", system);
+                CrystalPlacementBot.addPhysVolID("ix", ix);
+                CrystalPlacementBot.addPhysVolID("iy", iy);
+
+            }
+
+        }
+
+    }
+
+    public boolean isCalorimeter() {
+        return true;
+    }
 }

Modified: java/branches/HPSJAVA-409/detector-model/src/main/java/org/lcsim/geometry/subdetector/HPSEcal4.java
 =============================================================================
--- java/branches/HPSJAVA-409/detector-model/src/main/java/org/lcsim/geometry/subdetector/HPSEcal4.java	(original)
+++ java/branches/HPSJAVA-409/detector-model/src/main/java/org/lcsim/geometry/subdetector/HPSEcal4.java	Wed Apr 27 12:23:44 2016
@@ -5,16 +5,10 @@
 
 /**
  * Reconstruction version of HPS ECal with crystal array.
- * 
- * @author Jeremy McCormick <[log in to unmask]>
- * @author Timothy Nelson <[log in to unmask]>
- * @version $Id: HPSEcal4.java,v 1.3 2012/04/30 18:04:38 jeremy Exp $
  */
-//public class HPSEcal4 
-public class HPSEcal4 extends HPSEcal3{
-	
-	 HPSEcal4(Element node) throws JDOMException
-	    {
-	        super(node);
-	    }
-} 
+public class HPSEcal4 extends HPSEcal3 {
+
+    HPSEcal4(Element node) throws JDOMException {
+        super(node);
+    }
+}