Commit in projects/lcsim/trunk/detector-framework/src on MAIN
main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java+536-1343161 -> 3162
test/resources/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml+10-93161 -> 3162
+546-143
2 modified files
Added beamplane. Fixed c-support. Tried to locate in global but still something to hash out. Work in progress.

projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd
HPSTestRunTracker2014.java 3161 -> 3162
--- projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java	2014-06-27 05:35:36 UTC (rev 3161)
+++ projects/lcsim/trunk/detector-framework/src/main/java/org/lcsim/geometry/compact/converter/lcdd/HPSTestRunTracker2014.java	2014-07-01 01:07:35 UTC (rev 3162)
@@ -7,6 +7,7 @@
 import hep.physics.vec.Hep3Vector;
 import hep.physics.vec.VecOp;
 
+import java.text.NumberFormat;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -60,6 +61,9 @@
 	private final double support_plate_bottom_height = 12.7; //1/2"
 	private final double support_plate_bottom_length = 736.1;
 	private final double support_plate_bottom_width = 120.0;
+	private final double support_plate_top_height = support_plate_bottom_height;
+	private final double support_plate_top_length = support_plate_bottom_length;
+	private final double support_plate_top_width = support_plate_bottom_width;
 	private final double pedestal_height_L1 = 11.00;
 	private final double pedestal_height_L2 = 9.50;
 	private final double pedestal_height_L3 = 8.00;
@@ -99,37 +103,70 @@
 	// ball: hole
 	// vee:  slot
 	// flat: middle of pocket defining local w out of the pocket vertically
-	
-	private final Hep3Vector ball_pos_module1_support_plate_local = new BasicHep3Vector(25.0, 661.0, pedestal_height_L1-support_plate_pocket_depth);
-	private final Hep3Vector vee_pos_module1_support_plate_local = new BasicHep3Vector(95.0, 661.0, pedestal_height_L1-support_plate_pocket_depth);
-	//private final Hep3Vector flat_pos_module1_support_plate_local = new BasicHep3Vector(60.0, 655.10, pedestal_height_L1-support_plate_pocket_depth);
-	private final Hep3Vector flat_pos_module1_support_plate_local = new BasicHep3Vector(60.0, 667.10, pedestal_height_L1-support_plate_pocket_depth);
 
-	private final Hep3Vector ball_pos_module2_support_plate_local = new BasicHep3Vector(25.0, 561.0, pedestal_height_L2-support_plate_pocket_depth);
-	private final Hep3Vector vee_pos_module2_support_plate_local = new BasicHep3Vector(95.0, 561.0, pedestal_height_L2-support_plate_pocket_depth);
-	private final Hep3Vector flat_pos_module2_support_plate_local = new BasicHep3Vector(60.0, 567.10, pedestal_height_L2-support_plate_pocket_depth);
+	// bottom
+	private final Hep3Vector ball_pos_module1_support_plate_bottom_local = new BasicHep3Vector(25.0, 661.0, pedestal_height_L1-support_plate_pocket_depth);
+	private final Hep3Vector vee_pos_module1_support_plate_bottom_local = new BasicHep3Vector(95.0, 661.0, pedestal_height_L1-support_plate_pocket_depth);
+	private final Hep3Vector flat_pos_module1_support_plate_bottom_local = new BasicHep3Vector(60.0, 667.10, pedestal_height_L1-support_plate_pocket_depth);
 
-	private final Hep3Vector ball_pos_module3_support_plate_local = new BasicHep3Vector(25.0, 461.0, pedestal_height_L3-support_plate_pocket_depth);
-	private final Hep3Vector vee_pos_module3_support_plate_local = new BasicHep3Vector(95.0, 461.0, pedestal_height_L3-support_plate_pocket_depth);
-	private final Hep3Vector flat_pos_module3_support_plate_local = new BasicHep3Vector(60.0, 467.10, pedestal_height_L3-support_plate_pocket_depth);
+	private final Hep3Vector ball_pos_module2_support_plate_bottom_local = new BasicHep3Vector(25.0, 561.0, pedestal_height_L2-support_plate_pocket_depth);
+	private final Hep3Vector vee_pos_module2_support_plate_bottom_local = new BasicHep3Vector(95.0, 561.0, pedestal_height_L2-support_plate_pocket_depth);
+	private final Hep3Vector flat_pos_module2_support_plate_bottom_local = new BasicHep3Vector(60.0, 567.10, pedestal_height_L2-support_plate_pocket_depth);
 
-	private final Hep3Vector ball_pos_module4_support_plate_local = new BasicHep3Vector(25.0, 261.0, pedestal_height_L4-support_plate_pocket_depth);
-	private final Hep3Vector vee_pos_module4_support_plate_local = new BasicHep3Vector(95.0, 261.0, pedestal_height_L4-support_plate_pocket_depth);
-	private final Hep3Vector flat_pos_module4_support_plate_local = new BasicHep3Vector(60.0, 267.10, pedestal_height_L4-support_plate_pocket_depth);
+	private final Hep3Vector ball_pos_module3_support_plate_bottom_local = new BasicHep3Vector(25.0, 461.0, pedestal_height_L3-support_plate_pocket_depth);
+	private final Hep3Vector vee_pos_module3_support_plate_bottom_local = new BasicHep3Vector(95.0, 461.0, pedestal_height_L3-support_plate_pocket_depth);
+	private final Hep3Vector flat_pos_module3_support_plate_bottom_local = new BasicHep3Vector(60.0, 467.10, pedestal_height_L3-support_plate_pocket_depth);
 
-	private final Hep3Vector ball_pos_module5_support_plate_local = new BasicHep3Vector(25.0, 61.0, pedestal_height_L5-support_plate_pocket_depth);
-	private final Hep3Vector vee_pos_module5_support_plate_local = new BasicHep3Vector(95.0, 61.0, pedestal_height_L5-support_plate_pocket_depth);
-	private final Hep3Vector flat_pos_module5_support_plate_local = new BasicHep3Vector(60.0, 67.10, pedestal_height_L5-support_plate_pocket_depth);
+	private final Hep3Vector ball_pos_module4_support_plate_bottom_local = new BasicHep3Vector(25.0, 261.0, pedestal_height_L4-support_plate_pocket_depth);
+	private final Hep3Vector vee_pos_module4_support_plate_bottom_local = new BasicHep3Vector(95.0, 261.0, pedestal_height_L4-support_plate_pocket_depth);
+	private final Hep3Vector flat_pos_module4_support_plate_bottom_local = new BasicHep3Vector(60.0, 267.10, pedestal_height_L4-support_plate_pocket_depth);
+
+	private final Hep3Vector ball_pos_module5_support_plate_bottom_local = new BasicHep3Vector(25.0, 61.0, pedestal_height_L5-support_plate_pocket_depth);
+	private final Hep3Vector vee_pos_module5_support_plate_bottom_local = new BasicHep3Vector(95.0, 61.0, pedestal_height_L5-support_plate_pocket_depth);
+	private final Hep3Vector flat_pos_module5_support_plate_bottom_local = new BasicHep3Vector(60.0, 67.10, pedestal_height_L5-support_plate_pocket_depth);
+
+	// top
+
+	// top has a fixed offset of 15mm along plate on module pocket positions w.r.t. bottom
+	// top local coordinates is rotation pi around u-vec so need to adjust pocket depth coordinate
+
+	private final Hep3Vector ball_pos_module1_support_plate_top_local = new BasicHep3Vector(25.0, 676.1, -1.0 * (pedestal_height_L1-support_plate_pocket_depth));
+	private final Hep3Vector vee_pos_module1_support_plate_top_local = new BasicHep3Vector(95.0, 676.1, -1.0 * (pedestal_height_L1-support_plate_pocket_depth));
+	private final Hep3Vector flat_pos_module1_support_plate_top_local = new BasicHep3Vector(60.0, 670.1, -1.0 * (pedestal_height_L1-support_plate_pocket_depth));
+
+	private final Hep3Vector ball_pos_module2_support_plate_top_local = new BasicHep3Vector(25.0, 576.1, -1.0 * (pedestal_height_L2-support_plate_pocket_depth));
+	private final Hep3Vector vee_pos_module2_support_plate_top_local = new BasicHep3Vector(95.0, 576.1, -1.0 * (pedestal_height_L2-support_plate_pocket_depth));
+	private final Hep3Vector flat_pos_module2_support_plate_top_local = new BasicHep3Vector(60.0, 570.1, -1.0 * (pedestal_height_L2-support_plate_pocket_depth));
+
+	private final Hep3Vector ball_pos_module3_support_plate_top_local = new BasicHep3Vector(25.0, 476.1, -1.0 * (pedestal_height_L3-support_plate_pocket_depth));
+	private final Hep3Vector vee_pos_module3_support_plate_top_local = new BasicHep3Vector(95.0, 476.1, -1.0 * (pedestal_height_L3-support_plate_pocket_depth));
+	private final Hep3Vector flat_pos_module3_support_plate_top_local = new BasicHep3Vector(60.0, 470.1, -1.0 * (pedestal_height_L3-support_plate_pocket_depth));
+
+	private final Hep3Vector ball_pos_module4_support_plate_top_local = new BasicHep3Vector(25.0, 276.1, -1.0 * (pedestal_height_L4-support_plate_pocket_depth));
+	private final Hep3Vector vee_pos_module4_support_plate_top_local = new BasicHep3Vector(95.0, 276.1, -1.0 * (pedestal_height_L4-support_plate_pocket_depth));
+	private final Hep3Vector flat_pos_module4_support_plate_top_local = new BasicHep3Vector(60.0, 270.1, -1.0 * (pedestal_height_L4-support_plate_pocket_depth));
+
+	private final Hep3Vector ball_pos_module5_support_plate_top_local = new BasicHep3Vector(25.0, 76.1, -1.0 * (pedestal_height_L5-support_plate_pocket_depth));
+	private final Hep3Vector vee_pos_module5_support_plate_top_local = new BasicHep3Vector(95.0, 76.1, -1.0 * (pedestal_height_L5-support_plate_pocket_depth));
+	private final Hep3Vector flat_pos_module5_support_plate_top_local = new BasicHep3Vector(60.0, 70.1, -1.0 * (pedestal_height_L5-support_plate_pocket_depth));
+
 	
 	
+	
+	
+	
 	private final double base_plate_thickness = 0.25*inch;
 	private final double base_plate_width = 385.00;
 	private final double base_plate_length = 1216.00;
+	private final double base_plate_offset_height = 0.0;
 	private final double PS_vac_box_inner_height = 7.0*inch;
 	private final double PS_vac_box_plate_thickness = 0.75*inch;
-	private final double base_height = PS_vac_box_inner_height - PS_vac_box_plate_thickness; 
+	// height of the dummy box holding the entire SVT: this means the bottom of the base plate to the the inner surface of of the PS vac box for now
+	private final double base_height = PS_vac_box_inner_height - base_plate_offset_height; 
 	private final double base_width = base_plate_width;
 	private final double base_length = base_plate_length;
+	private final double beamPlaneThickness = 0.00000001;
+	private final double base_plate_offset_from_edge = 1.0*inch;
 	
 
 	
@@ -194,6 +231,9 @@
 			print(String.format("coord_tracking:\n%s", coord_tracking.toString()));
 		}
 		
+
+		makeExample(lcdd,sens);
+
 		
 		// Surveyed position of the base plate in the JLab/tracking volume
 		// Use edges of plate instead of real survey balls for now
@@ -202,15 +242,40 @@
 		// length - v - global -z
 		// thickness - w - global y	
 		
-		Hep3Vector ball_pos_base_plate = new BasicHep3Vector(0,0,0);
-		Hep3Vector vee_pos_base_plate = new BasicHep3Vector(base_plate_width,ball_pos_base_plate.y(),ball_pos_base_plate.z());
-		Hep3Vector flat_pos_base_plate = new BasicHep3Vector(ball_pos_base_plate.x(), ball_pos_base_plate.y(), ball_pos_base_plate.z() - base_plate_length);
+		// ball at the upper (vertically) downstream edge of the base plate on the electron side
+		// vee at the upper (vertically) downstream edge of the base plate on the positron side
+		// flat at the upper (vertically) upstream edge of the base plate on the electron side
+		
+		// The tracking coordinate system is located at the target position.
+		// The base plate is located flush against the upstream edge of the PS vacuum box
+		// The pole face of the PS magnet is 12" from that edge
+		// The x=0 is centered on the support plate width at the target position in z( TODO: really?)
+		// The beam is at y=0 in the center of the PS vac box
+		
+		final double ball_pos_base_plate_x = -1.0*base_plate_width/2.0;
+		final double ball_pos_base_plate_y = -1.0*PS_vac_box_inner_height/2.0 + base_plate_thickness + base_plate_offset_height;
+		final double ball_pos_base_plate_z = base_plate_length - 12.0*inch + base_plate_offset_from_edge ;
+		final double vee_pos_base_plate_x = ball_pos_base_plate_x + base_plate_width;
+		final double vee_pos_base_plate_y = ball_pos_base_plate_y;
+		final double vee_pos_base_plate_z = ball_pos_base_plate_z;
+		final double flat_pos_base_plate_x = ball_pos_base_plate_x;
+		final double flat_pos_base_plate_y = ball_pos_base_plate_y;
+		final double flat_pos_base_plate_z = ball_pos_base_plate_z - base_plate_length;
+		Hep3Vector ball_pos_base_plate = new BasicHep3Vector(ball_pos_base_plate_x, ball_pos_base_plate_y, ball_pos_base_plate_z);
+		Hep3Vector vee_pos_base_plate = new BasicHep3Vector(vee_pos_base_plate_x,vee_pos_base_plate_y,vee_pos_base_plate_z);
+		Hep3Vector flat_pos_base_plate = new BasicHep3Vector(flat_pos_base_plate_x, flat_pos_base_plate_y, flat_pos_base_plate_z);
+		
+		print(String.format("ball_pos_base_plate: %s", ball_pos_base_plate.toString()));
+		print(String.format("vee_pos_base_plate: %s", vee_pos_base_plate.toString()));
+		print(String.format("flat_pos_base_plate: %s", flat_pos_base_plate.toString()));
+		
 
-		//		Hep3Vector ball_pos_base_plate = new BasicHep3Vector(-1*this.base_plate_width/2.0, -1.0*this.base_height/2.0+this.base_plate_thickness,this.base_length/2.0);
-//		Hep3Vector vee_pos_base_plate = new BasicHep3Vector(ball_pos_base_plate.x()+this.base_plate_width,ball_pos_base_plate.y(),ball_pos_base_plate.z());
-//		Hep3Vector flat_pos_base_plate = new BasicHep3Vector(ball_pos_base_plate.x(),ball_pos_base_plate.y(),ball_pos_base_plate.z()-this.base_plate_length);
+		// beam plane at global z=0
+		Hep3Vector ball_pos_beamplane = new BasicHep3Vector(-1.0*base_plate_width/2.0,0.0,base_plate_length/2.0);
+		Hep3Vector vee_pos_beamplane = new BasicHep3Vector(ball_pos_beamplane.x()+base_plate_width,ball_pos_beamplane.y(),ball_pos_beamplane.z());
+		Hep3Vector flat_pos_beamplane = new BasicHep3Vector(ball_pos_beamplane.x(), ball_pos_beamplane.y(), ball_pos_beamplane.z()-base_plate_length/2.0);
 		
-		makeExample(lcdd,sens);
+		makeBeamPlane(trackingWrap, ball_pos_beamplane, vee_pos_beamplane, flat_pos_beamplane, lcdd, sens);
 		
 		makeBase(trackingWrap, ball_pos_base_plate, vee_pos_base_plate, flat_pos_base_plate, lcdd, sens );
 				
@@ -248,7 +313,7 @@
 		Transform3D trans_base_to_tracking = getTransformation(base_coord);
 		
 		String volName = "base";
-		Box box = new Box(volName + "Box", base_width, base_length , base_height);
+		Box box = new Box(volName + "Box", base_width, base_length, base_height);
 		lcdd.add(box);
 		Volume baseVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Vacuum"));
 
@@ -260,7 +325,7 @@
 		}
 
 		
-		// Find distance to center in the local coordinate system 
+		
 		Hep3Vector box_center_base_local = new BasicHep3Vector(base_width/2.0, base_length/2.0, base_height/2.0 - base_plate_thickness);
 		
 		//translate to the mother coordinate system
@@ -297,9 +362,9 @@
 		baseWrap.center = box_center_base_local;
 		
 		
-		// create the base plate inside the support box 
+		// create the base plate inside the base tracker box 
 
-		// need to create new local survey points since it's w.r.t. to the base volume
+		// need to create new local survey points since it's w.r.t. to the local coordinates of the base volume
 		
 		if(_debug) {
 			print(String.format("ball_pos_base_plate %s", ball_pos_base_plate.toString()));
@@ -321,43 +386,249 @@
 		
 		makeBasePlate(baseWrap, ball_pos_base_plate_2, vee_pos_base_plate_2, flat_pos_base_plate_2, lcdd, sens );
 		
-	
+
+		// create the box around the support plates w.r.t. base plate survey positions
+
 		if(_debug) {
 			print("Make c-support positions on base plate for bottom");
 		}
 		
-		// create the box around the support plate w.r.t. base plate 
-		// ball position is C-support pin position on electron side
-		// vee position is C-support pin position on positron side
-		// flat position is a randomly chosen point perpendicular to ball to vee vector starting from 
-		// the ball position and offset 10mm at same vertical position. 
-		final double ball_pos_csup_x = 385.0 - 271.05;
-		final double ball_pos_csup_y = 121.62;
-		final double ball_pos_csup_z = 0.0;
-		final double vee_pos_csup_x = 385.0 - 51.15;
-		final double vee_pos_csup_y = 115.02;
-		final double vee_pos_csup_z = 0.0;
-		// find the arbitrary flat position (10.0mm in support plate direction)
-		// this is the rotation angle around the local w of the c-support
-		final double rot_angle_local_w = Math.asin( (vee_pos_csup_y - ball_pos_csup_y)/(vee_pos_csup_x - ball_pos_csup_x));
-		final double flat_pos_csup_x = ball_pos_csup_x - 10.0 * Math.sin(rot_angle_local_w);
-		final double flat_pos_csup_y = ball_pos_csup_y + 10.0 * Math.cos(rot_angle_local_w);
-		final double flat_pos_csup_z = 0.0;
+		// This is the sequence of locating the support plate positions:
+		// The c-support pin positions are found
+		// the points on the axis of rotation are used as references for building the box surrounding the support plates (incl sensors).
+		// this should make it more straightforward when applying a tilt angle
+		// c-support:
+		// ball position is C-support pin position on electron side on the base plate surface
+		// vee position is C-support pin position on positron side on the base plate surface
+		// flat position is a randomly chosen point perpendicular to ball to vee vector and offset 10mm along the plate. 
+		// Note that the flat here sets the tilt angle of the support plates.
 		
-		Hep3Vector ball_pos_csup = new BasicHep3Vector(ball_pos_csup_x,ball_pos_csup_y,ball_pos_csup_z);
-		Hep3Vector vee_pos_csup = new BasicHep3Vector(vee_pos_csup_x,vee_pos_csup_y,vee_pos_csup_z);
-		Hep3Vector flat_pos_csup = new BasicHep3Vector(flat_pos_csup_x,flat_pos_csup_y,flat_pos_csup_z);
+		// pin position on base plate surface
+		double ball_pos_csup_pin_bottom_x = 51.15;
+		double ball_pos_csup_pin_bottom_y = 115.02;
+		double ball_pos_csup_pin_bottom_z = 0.0;
+		double vee_pos_csup_pin_bottom_x = 271.05;
+		double vee_pos_csup_pin_bottom_y = 121.62;
+		double vee_pos_csup_pin_bottom_z = 0.0;
+		// find the rotation to place the flat point
+		org.apache.commons.math3.geometry.euclidean.threed.Rotation rot1_csup = 
+				new org.apache.commons.math3.geometry.euclidean.threed.Rotation(
+						new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(vee_pos_csup_pin_bottom_x-ball_pos_csup_pin_bottom_x,
+																						vee_pos_csup_pin_bottom_y-ball_pos_csup_pin_bottom_y,
+																						vee_pos_csup_pin_bottom_z-ball_pos_csup_pin_bottom_z),
+																						new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(1,0,0));
+						
+		org.apache.commons.math3.geometry.euclidean.threed.Vector3D flat_pos_csup_pin_bottom_3D_rot = rot1_csup.applyTo(new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(0,10.0,0));
+		// translate
+		double flat_pos_csup_pin_bottom_x = ball_pos_csup_pin_bottom_x + flat_pos_csup_pin_bottom_3D_rot.getX();
+		double flat_pos_csup_pin_bottom_y = ball_pos_csup_pin_bottom_y + flat_pos_csup_pin_bottom_3D_rot.getY();
+		double flat_pos_csup_pin_bottom_z = ball_pos_csup_pin_bottom_z + flat_pos_csup_pin_bottom_3D_rot.getZ();
+
+		// make vectors
+		Hep3Vector ball_pos_csup_pin_bottom = new BasicHep3Vector(ball_pos_csup_pin_bottom_x,ball_pos_csup_pin_bottom_y,ball_pos_csup_pin_bottom_z);
+		Hep3Vector vee_pos_csup_pin_bottom = new BasicHep3Vector(vee_pos_csup_pin_bottom_x,vee_pos_csup_pin_bottom_y,vee_pos_csup_pin_bottom_z);	
+		Hep3Vector flat_pos_csup_pin_bottom = new BasicHep3Vector(flat_pos_csup_pin_bottom_x,flat_pos_csup_pin_bottom_y,flat_pos_csup_pin_bottom_z);
+				
+		// create the coordinate system of the c-support pin
+		CoordSysDef csup_pin_coord = new CoordSysDef(ball_pos_csup_pin_bottom, vee_pos_csup_pin_bottom, flat_pos_csup_pin_bottom);		
+		Transform3D trans_csup_pin_to_base = getTransformation(csup_pin_coord);
+
+		if(_debug) {
+			print(String.format("Creating the c-support pin positions\n"));
+			print(String.format("ball_pos_csup_pin_bottom 			%s", ball_pos_csup_pin_bottom.toString()));
+			print(String.format("vee_pos_csup_pin_bottom            %s", vee_pos_csup_pin_bottom.toString()));
+			double csup_rot1_angles[] = rot1_csup.getAngles(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ);
+			print(String.format("rot1_csup angles (XYZ)  (%f,%f,%f) ",csup_rot1_angles[0],csup_rot1_angles[1],csup_rot1_angles[2]));
+			print(String.format("flat_pos_csup_pin_bottom_3D_rot   (%f,%f,%f) ", flat_pos_csup_pin_bottom_3D_rot.getX(),flat_pos_csup_pin_bottom_3D_rot.getY(),flat_pos_csup_pin_bottom_3D_rot.getZ()));
+			print(String.format("flat_pos_csup_pin_bottom           %s", flat_pos_csup_pin_bottom.toString()));
+			print(String.format("csup_pin_coord:\n%s ", csup_pin_coord.toString()));
+			print(String.format("trans_csup_pin_to_base:\n%s ", trans_csup_pin_to_base.toString()));
+			
+		}
 		
+		// now create the support box which will have it's coordinates at the rotation axis point so that flat determines the tilt of the plates
+		// it will referenced locally to the c-support pin coordinate system 
+
+		// point on axis of rotation on the inside of the c-support frame where the insert get's attached
+		double ball_pos_csup_bearings_bottom_x = 240.0 - 265.0 + 14.0;
+		double ball_pos_csup_bearings_bottom_y = (-6.0 + 22.0);
+		double ball_pos_csup_bearings_bottom_z = 14.7;
+		
+		double vee_pos_csup_bearings_bottom_x = 240.0- 129.0;
+		double vee_pos_csup_bearings_bottom_y = (-6.0 + 22.0);
+		double vee_pos_csup_bearings_bottom_z = 14.7;
+		
+		// use an arbitrary local flat position: 10.0mm along the support plate direction
+		double flat_pos_csup_bearings_bottom_x = ball_pos_csup_bearings_bottom_x;
+		double flat_pos_csup_bearings_bottom_y = ball_pos_csup_bearings_bottom_y + 10.0;
+		double flat_pos_csup_bearings_bottom_z = ball_pos_csup_bearings_bottom_z;
+		
+		// make vectors
+		Hep3Vector ball_pos_csup_bearings_bottom = new BasicHep3Vector(ball_pos_csup_bearings_bottom_x,ball_pos_csup_bearings_bottom_y,ball_pos_csup_bearings_bottom_z);
+		Hep3Vector vee_pos_csup_bearings_bottom = new BasicHep3Vector(vee_pos_csup_bearings_bottom_x,vee_pos_csup_bearings_bottom_y,vee_pos_csup_bearings_bottom_z);	
+		
+		// use a settable rotation to effectively determine the flat and therefore the tilt of the support 
+		final double csup_bottom_rot_angle_local_u = 0.0;
+		
+		// build the rotation to find the proper location of the flat
+		org.apache.commons.math3.geometry.euclidean.threed.Rotation rot_csup = 
+				new org.apache.commons.math3.geometry.euclidean.threed.Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ, 
+						csup_bottom_rot_angle_local_u, 0.0, 0.0 );
+		// apply to flat local position
+		org.apache.commons.math3.geometry.euclidean.threed.Vector3D flat_pos_csup_bearings_bottom_3D_rot = 
+				rot_csup.applyTo(new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(0.0,10.0,0.0));
+		// translate
+		flat_pos_csup_bearings_bottom_x = ball_pos_csup_bearings_bottom_x + flat_pos_csup_bearings_bottom_3D_rot.getX();
+		flat_pos_csup_bearings_bottom_y = ball_pos_csup_bearings_bottom_y + flat_pos_csup_bearings_bottom_3D_rot.getY();
+		flat_pos_csup_bearings_bottom_z = ball_pos_csup_bearings_bottom_z + flat_pos_csup_bearings_bottom_3D_rot.getZ();
+		Hep3Vector flat_pos_csup_bearings_bottom = new BasicHep3Vector(flat_pos_csup_bearings_bottom_x,flat_pos_csup_bearings_bottom_y,flat_pos_csup_bearings_bottom_z);
+
+		// create the coordinate system of the c-support bearings
+		CoordSysDef csup_bearings_bottom_coord = new CoordSysDef(ball_pos_csup_bearings_bottom, vee_pos_csup_bearings_bottom, flat_pos_csup_bearings_bottom);		
+		//Transform3D trans_csup_bearings_to_pin = getTransformation(csup_pin_coord);
+
+		
+
 		if(_debug) {
-			print(String.format("rot_angle_local_w %f", rot_angle_local_w));
-			print(String.format("ball_pos_csup %s", ball_pos_csup.toString()));
-			print(String.format("vee_pos_csup %s", vee_pos_csup.toString()));
-			print(String.format("flat_pos_csup %s", flat_pos_csup.toString()));
+			print(String.format("Creating the c-support bearings\n"));
+			print(String.format("ball_pos_csup_bearings_bottom 			 %s", ball_pos_csup_bearings_bottom.toString()));
+			print(String.format("vee_pos_csup_bearings_bottom            %s", vee_pos_csup_bearings_bottom.toString()));
+			print(String.format("csup_bottom_rot_angle_local_u           %f", csup_bottom_rot_angle_local_u ));
+			print(String.format("flat_pos_csup_bearings_bottom           %s", flat_pos_csup_bearings_bottom.toString()));
+			print(String.format("csup_bearings_coord:\n%s ", csup_bearings_bottom_coord.toString()));
+			//print(String.format("trans_csup_bearings_to_pin:\n%s ", trans_csup_bearings_to_pin.toString()));
 		}
+
+
+		// since we don't care (no volume is built) about the local position of the bearings in the pin coord system we'll get rid of it
+		// and find the bearings position in the base coordinate system directly
+		Hep3Vector ball_pos_csup_bottom = trans_csup_pin_to_base.transformed(ball_pos_csup_bearings_bottom);
+		Hep3Vector vee_pos_csup_bottom = trans_csup_pin_to_base.transformed(vee_pos_csup_bearings_bottom);
+		Hep3Vector flat_pos_csup_bottom = trans_csup_pin_to_base.transformed(flat_pos_csup_bearings_bottom);
 		
-		makeSupport("bottom", baseWrap, ball_pos_csup, vee_pos_csup, flat_pos_csup, lcdd, sens );
-				
+		if(_debug) {
+			print(String.format("Creating the c-support in base coordinates\n"));
+			print(String.format("ball_pos_csup_bottom 			 %s", ball_pos_csup_bottom.toString()));
+			print(String.format("vee_pos_csup_bottom             %s", vee_pos_csup_bottom.toString()));
+			print(String.format("flat_pos_csup_bottom            %s", flat_pos_csup_bottom.toString()));
+		}
 		
+		
+		
+	
+		makeSupport("bottom", baseWrap, ball_pos_csup_bottom, vee_pos_csup_bottom, flat_pos_csup_bottom, lcdd, sens );
+
+	
+
+		if(_debug) {
+			print("Make c-support positions on base plate for top");
+		}
+
+		// the top has the same bearing positions as the bottom c-support except for the offset vertically from base plate
+		// the tilt angle is independent though.
+		
+		Hep3Vector ball_pos_csup_bearings_top = new BasicHep3Vector(ball_pos_csup_bearings_bottom.x(),
+																	ball_pos_csup_bearings_bottom.y(),
+																	ball_pos_csup_bearings_bottom.z() + 146.4);
+		Hep3Vector vee_pos_csup_bearings_top = new BasicHep3Vector(vee_pos_csup_bearings_bottom.x(),
+																	vee_pos_csup_bearings_bottom.y(),
+																	vee_pos_csup_bearings_bottom.z() + 146.4);
+		
+		// use a settable rotation to effectively determine the flat and therefore the tilt of the support 
+		final double csup_top_rot_angle_local_u = 0.0;
+
+		// build the rotation to find the proper location of the flat
+		org.apache.commons.math3.geometry.euclidean.threed.Rotation rot_csup_top = 
+				new org.apache.commons.math3.geometry.euclidean.threed.Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ, 
+						csup_top_rot_angle_local_u, 0.0, 0.0 );
+		// apply to flat local position (as for bottom it is arbitrary offset)
+		org.apache.commons.math3.geometry.euclidean.threed.Vector3D flat_pos_csup_bearings_top_3D_rot = 
+				rot_csup.applyTo(new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(0.0,10.0,0.0));
+		// translate the flat position
+		double flat_pos_csup_bearings_top_x = ball_pos_csup_bearings_top.x() + flat_pos_csup_bearings_top_3D_rot.getX();
+		double flat_pos_csup_bearings_top_y = ball_pos_csup_bearings_top.y() + flat_pos_csup_bearings_top_3D_rot.getY();
+		double flat_pos_csup_bearings_top_z = ball_pos_csup_bearings_top.z() + flat_pos_csup_bearings_top_3D_rot.getZ();
+		Hep3Vector flat_pos_csup_bearings_top = new BasicHep3Vector(flat_pos_csup_bearings_top_x,flat_pos_csup_bearings_top_y,flat_pos_csup_bearings_top_z);
+
+		// create the coordinate system of the c-support bearings
+		CoordSysDef csup_bearings_top_coord = new CoordSysDef(ball_pos_csup_bearings_top, vee_pos_csup_bearings_top, flat_pos_csup_bearings_top);		
+		//Transform3D trans_csup_bearings_to_pin = getTransformation(csup_pin_coord);
+
+
+
+		if(_debug) {
+			print(String.format("Creating the c-support bearings for top\n"));
+			print(String.format("ball_pos_csup_bearings_top 		  %s", ball_pos_csup_bearings_top.toString()));
+			print(String.format("vee_pos_csup_bearings_top            %s", vee_pos_csup_bearings_top.toString()));
+			print(String.format("csup_top_rot_angle_local_u           %f", csup_top_rot_angle_local_u ));
+			print(String.format("flat_pos_csup_bearings_top           %s", flat_pos_csup_bearings_top.toString()));
+			print(String.format("csup_bearings_top_coord:\n%s ", csup_bearings_top_coord.toString()));
+			//print(String.format("trans_csup_bearings_to_pin:\n%s ", trans_csup_bearings_to_pin.toString()));
+		}
+
+		// similar to for bottom, find the bearing positions in the base coord directly
+		Hep3Vector ball_pos_csup_top = trans_csup_pin_to_base.transformed(ball_pos_csup_bearings_top);
+		Hep3Vector vee_pos_csup_top = trans_csup_pin_to_base.transformed(vee_pos_csup_bearings_top);
+		Hep3Vector flat_pos_csup_top = trans_csup_pin_to_base.transformed(flat_pos_csup_bearings_top);
+
+		if(_debug) {
+			print(String.format("Creating the c-support in base coordinates\n"));
+			print(String.format("ball_pos_csup_top 			 %s", ball_pos_csup_top.toString()));
+			print(String.format("vee_pos_csup_top             %s", vee_pos_csup_top.toString()));
+			print(String.format("flat_pos_csup_top            %s", flat_pos_csup_top.toString()));
+		}
+
+		makeSupport("top", baseWrap, ball_pos_csup_top, vee_pos_csup_top, flat_pos_csup_top, lcdd, sens );
+
+		
+		
+		
+//		
+//
+//		final double ball_pos_csup_top_x = ball_pos_csup_bearings_bottom_x; //+ csup_top_offset_x;
+//		final double ball_pos_csup_top_y = ball_pos_csup_bearings_bottom_y;
+//		final double ball_pos_csup_top_z = ball_pos_csup_bearings_bottom_z + 200.0; // TODO get the real number from c-support drawing
+//
+//		final double vee_pos_csup_top_x = vee_pos_csup_bearings_bottom_x; //51.15 + csup_top_offset_x;
+//		final double vee_pos_csup_top_y = vee_pos_csup_bearings_bottom_y;
+//		final double vee_pos_csup_top_z = ball_pos_csup_top_z;
+//		
+////		final double ball_pos_csup_top_x = ball_pos_csup_bottom_x; //51.15 + csup_top_offset_x;
+////		final double ball_pos_csup_top_y = 115.02;
+////		final double ball_pos_csup_top_z = 100.0;
+////		final double vee_pos_csup_top_x = 271.05 + csup_top_offset_x;
+////		final double vee_pos_csup_top_y = 121.62;
+////		final double vee_pos_csup_top_z = ball_pos_csup_top_z;
+//		// use an arbitrary flat position: 10.0mm in support plate direction
+//		// the ball and vee position above sets the rotation angle of the c-support
+//		final double csup_top_rot_angle_local_w = Math.asin( (vee_pos_csup_top_y - ball_pos_csup_top_y)/(vee_pos_csup_top_x - ball_pos_csup_top_x) );
+//		final double flat_pos_csup_top_x = ball_pos_csup_top_x - 10.0 * Math.sin(csup_top_rot_angle_local_w);
+//		final double flat_pos_csup_top_y = ball_pos_csup_top_y + 10.0 * Math.cos(csup_top_rot_angle_local_w);
+//		final double flat_pos_csup_top_z = ball_pos_csup_top_z;
+//		
+//		Hep3Vector ball_pos_csup_top = new BasicHep3Vector(ball_pos_csup_top_x,ball_pos_csup_top_y,ball_pos_csup_top_z);
+//		Hep3Vector vee_pos_csup_top = new BasicHep3Vector(vee_pos_csup_top_x,vee_pos_csup_top_y,vee_pos_csup_top_z);
+//		Hep3Vector flat_pos_csup_top = new BasicHep3Vector(flat_pos_csup_top_x,flat_pos_csup_top_y,flat_pos_csup_top_z);
+//		
+//		if(_debug) {
+//			print(String.format("csup_top_rot_angle_local_w %f", csup_top_rot_angle_local_w));
+//			print(String.format("ball_pos_csup_top %s", ball_pos_csup_top.toString()));
+//			print(String.format("vee_pos_csup_top %s", vee_pos_csup_top.toString()));
+//			print(String.format("flat_pos_csup_top %s", flat_pos_csup_top.toString()));
+//		}
+		
+		
+	
+	
+		
+		
+		
+		
+		
+		
+		
+		
+		
 		//baseVolume.setVisAttributes(lcdd.getVisAttributes("BasePlateVis"));
 		lcdd.add(baseVolume);
 		
@@ -468,13 +739,13 @@
 	
 	
 	
-	private void makeSupport(String name, VolWrapper baseWrap, 
+	private void makeSupport(String half, VolWrapper baseWrap, 
 							Hep3Vector ball_pos_csup, Hep3Vector vee_pos_csup, Hep3Vector flat_pos_csup,
 							LCDD lcdd, SensitiveDetector sens) throws JDOMException {
 		
 
 		if(_debug) {
-			print("--- makeSupport for " + name + " half ----");
+			print("--- makeSupport for " + half + " half ----");
 			
 		}
 		
@@ -482,18 +753,24 @@
 		double support_length = -99999.9;
 		double support_width = -99999.9;
 		double support_height = -99999.9;
+		double support_plate_length = -99999.9;
+		double support_plate_width = -99999.9;
 		
-		if( name == "bottom" ) {
+		if( half == "bottom" ) {
 			support_length = support_bottom_length;
 			support_width = support_bottom_width;
 			support_height = support_bottom_height;
+			support_plate_length = support_plate_bottom_length;
+			support_plate_width = support_plate_bottom_width;
 		}
-		else if( name == "top" ) {
+		else if( half == "top" ) {
 			support_length = support_top_length;
 			support_width = support_top_width;
 			support_height = support_top_height;
+			support_plate_length = support_plate_top_length;
+			support_plate_width = support_plate_top_width;
 		} else {
-			print("Error: cannot make support for " + name);
+			print("Error: cannot make support for " + half);
 			System.exit(1);
 		}
 		
@@ -504,7 +781,7 @@
 		
 				
 		
-		String volName = "support_" + name;
+		String volName = "support_" + half;
 		Box box = new Box(volName + "Box", support_width, support_length, support_height);
 		lcdd.add(box);
 		Volume supportVolume = new Volume(volName + "_volume", box, lcdd.getMaterial("Vacuum"));
@@ -521,8 +798,19 @@
 
 
 		// Find distance to center in the local coordinate system 
-		Hep3Vector box_center_support_local = new BasicHep3Vector(support_bottom_width/2.0, support_bottom_length/2.0, support_bottom_height/2.0);
 		
+		// the support plate sits exactly in between the bearing positions
+		// it's offset along the local directions
+		
+		Hep3Vector box_center_support_local;
+		if(half == "bottom") {
+			//box_center_support_local = new BasicHep3Vector(support_width/2.0, support_length/2.0, support_height/2.0);
+			box_center_support_local = new BasicHep3Vector(support_width/2.0+1.0, support_length/2.0 + (17.00-10.50/2.0), support_height/2.0 - (12.70-6.66-1.34));
+		} else {
+			//box_center_support_local = new BasicHep3Vector(support_width/2.0, support_length/2.0, -1.0 * support_height/2.0);
+			box_center_support_local = new BasicHep3Vector(support_width/2.0+1.0, support_length/2.0 + (17.00-10.50/2.0), -1.0 * (support_height/2.0 - (12.70-6.66-1.34)));
+		} 
+		
 		//translate to the mother coordinate system
 		Hep3Vector box_center_support_base = trans_csup_to_base.transformed(box_center_support_local);
 		
@@ -566,15 +854,26 @@
 		
 		// create the support plate inside the support box coordinate system
 		// survey points on the support plate are: 
-		// ball: corner of the hinge end at the surface on the electron side
-		// vee: corner of the hinge end at the surface on the positron side
+		// ball: corner of the hinge end at the surface on the side where module cold blocks are
+		// vee: corner of the hinge end at the surface on the side where sensors are
 		// flat: middle of plate at upstream end at the surface
+
+		Hep3Vector ball_pos_support_plate;
+		Hep3Vector vee_pos_support_plate;
+		Hep3Vector flat_pos_support_plate;
+		if(half == "bottom") {
+			ball_pos_support_plate = new BasicHep3Vector(1.0, (17.00-10.50/2.0), 6.66+1.34); 
+			vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
+			flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_length,ball_pos_support_plate.z());
+			//ball_pos_support_plate = new BasicHep3Vector(0.0, 0.0, support_plate_height); // TODO figure out what height this should be from the C-support drawings
+			//vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
+			//flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_length,ball_pos_support_plate.z());
+		} else {
+			ball_pos_support_plate = new BasicHep3Vector(1.0, (17.00-10.50/2.0), -1.0 * (6.66+1.34)); // TODO figure out what height this should be from the C-support drawings
+			vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
+			flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_length,ball_pos_support_plate.z());
+		}
 		
-		// TODO figure out what height this should be
-		Hep3Vector ball_pos_support_plate = new BasicHep3Vector(0.0, 0.0, support_plate_bottom_height);
-		Hep3Vector vee_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x() + support_plate_bottom_width, ball_pos_support_plate.y(),ball_pos_support_plate.z());
-		Hep3Vector flat_pos_support_plate = new BasicHep3Vector(ball_pos_support_plate.x(), ball_pos_support_plate.y() + support_plate_bottom_length,ball_pos_support_plate.z());
-		
 		makeSupportPlate(supportWrap, ball_pos_support_plate, vee_pos_support_plate, flat_pos_support_plate, lcdd, sens );
 
 		
@@ -584,8 +883,8 @@
 			
 		
 		// create the module from positions of module ball, vee and flat w.r.t. support plate survey points
-		// ball: hole on electron side
-		// vee:  slot on the positron side
+		// ball: hole on the cold block mounting surface
+		// vee:  slot on the cold block mounting surface
 		// flat: midpoint between line joining ball and vee and offset 90deg along plate going upstream
 		
 		if(_debug) {
@@ -594,7 +893,7 @@
 		
 		for(int ilayer = 1; ilayer <=5; ++ilayer) {
 
-			String layerName = String.format("L%db", ilayer);
+			String layerName = String.format("L%d%s", ilayer,half=="bottom"?"b":"t");
 			
 			print(layerName);
 
@@ -602,33 +901,63 @@
 			Hep3Vector vee_pos_mod_local = null;
 			Hep3Vector flat_pos_mod_local = null;
 			if(ilayer == 1) {
-				 ball_pos_mod_local = ball_pos_module1_support_plate_local;
-				 vee_pos_mod_local = vee_pos_module1_support_plate_local;
-				 flat_pos_mod_local = flat_pos_module1_support_plate_local;
+				if(half == "bottom") {
+					ball_pos_mod_local = ball_pos_module1_support_plate_bottom_local;
+					vee_pos_mod_local = vee_pos_module1_support_plate_bottom_local;
+					flat_pos_mod_local = flat_pos_module1_support_plate_bottom_local;
+				} else {
+					ball_pos_mod_local = ball_pos_module1_support_plate_top_local;
+					vee_pos_mod_local = vee_pos_module1_support_plate_top_local;
+					flat_pos_mod_local = flat_pos_module1_support_plate_top_local;
+				}
+			}	
+			else if (ilayer == 2) {
+				if(half == "bottom") {
+					ball_pos_mod_local = ball_pos_module2_support_plate_bottom_local;
+					vee_pos_mod_local = vee_pos_module2_support_plate_bottom_local;
+					flat_pos_mod_local = flat_pos_module2_support_plate_bottom_local;
+				} else {
+					ball_pos_mod_local = ball_pos_module2_support_plate_top_local;
+					vee_pos_mod_local = vee_pos_module2_support_plate_top_local;
+					flat_pos_mod_local = flat_pos_module2_support_plate_top_local;
+				} 
 			}
-			else if (ilayer == 2) {
-				 ball_pos_mod_local = ball_pos_module2_support_plate_local;
-				 vee_pos_mod_local = vee_pos_module2_support_plate_local;
-				 flat_pos_mod_local = flat_pos_module2_support_plate_local;
-			} 
 			else if (ilayer == 3) {
-				ball_pos_mod_local = ball_pos_module3_support_plate_local;
-				vee_pos_mod_local = vee_pos_module3_support_plate_local;
-				flat_pos_mod_local = flat_pos_module3_support_plate_local;
-			} 
+				if(half == "bottom") {
+					ball_pos_mod_local = ball_pos_module3_support_plate_bottom_local;
+					vee_pos_mod_local = vee_pos_module3_support_plate_bottom_local;
+					flat_pos_mod_local = flat_pos_module3_support_plate_bottom_local;
+				} else {
+					ball_pos_mod_local = ball_pos_module3_support_plate_top_local;
+					vee_pos_mod_local = vee_pos_module3_support_plate_top_local;
+					flat_pos_mod_local = flat_pos_module3_support_plate_top_local;
+				} 
+			}
 			else if (ilayer == 4) {
-				ball_pos_mod_local = ball_pos_module4_support_plate_local;
-				vee_pos_mod_local = vee_pos_module4_support_plate_local;
-				flat_pos_mod_local = flat_pos_module4_support_plate_local;
+				if(half == "bottom") {
+					ball_pos_mod_local = ball_pos_module4_support_plate_bottom_local;
+					vee_pos_mod_local = vee_pos_module4_support_plate_bottom_local;
+					flat_pos_mod_local = flat_pos_module4_support_plate_bottom_local;
+				} else {
+					ball_pos_mod_local = ball_pos_module4_support_plate_top_local;
+					vee_pos_mod_local = vee_pos_module4_support_plate_top_local;
+					flat_pos_mod_local = flat_pos_module4_support_plate_top_local;
+				}
 			} else if (ilayer == 5) {
-				ball_pos_mod_local = ball_pos_module5_support_plate_local;
-				vee_pos_mod_local = vee_pos_module5_support_plate_local;
-				flat_pos_mod_local = flat_pos_module5_support_plate_local;
+				if(half == "bottom") {
+					ball_pos_mod_local = ball_pos_module5_support_plate_bottom_local;
+					vee_pos_mod_local = vee_pos_module5_support_plate_bottom_local;
+					flat_pos_mod_local = flat_pos_module5_support_plate_bottom_local;
+				} else {
+					ball_pos_mod_local = ball_pos_module5_support_plate_top_local;
+					vee_pos_mod_local = vee_pos_module5_support_plate_top_local;
+					flat_pos_mod_local = flat_pos_module5_support_plate_top_local;
+				}
 			} else {
 				print("Not more than 5 layers!");
 				System.exit(1);
 			}
-			
+
 			if(_debug) {
 				print(String.format("ball_pos_mod_local %s", ball_pos_mod_local.toString()));
 				print(String.format("vee_pos_mod_local  %s", vee_pos_mod_local.toString()));
@@ -661,8 +990,9 @@
 			}
 			
 			// make the module
-			makeModule(layerName,supportWrap, ball_pos_mod, vee_pos_mod, flat_pos_mod,lcdd, sens);
-		
+//			if(name=="bottom") {
+				makeModule(layerName,supportWrap, ball_pos_mod, vee_pos_mod, flat_pos_mod,lcdd, sens);
+//			}
 		} // ilayer
 		
 		
@@ -687,8 +1017,11 @@
 			Hep3Vector vee_pos_support_plate,
 			Hep3Vector flat_pos_support_plate, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
 
+
+		String half = getHalfFromName(supportWrap.name);
+		
 		if(_debug) {
-			print("--- makeSupportPlate for half ----");
+			print("--- makeSupportPlate for " + half + " ----");
 			
 		}
 		
@@ -714,7 +1047,12 @@
 		
 		
 		// Find distance to center in the local coordinate system 
-		Hep3Vector box_center_support_plate_local = new BasicHep3Vector(support_plate_bottom_width/2.0, support_plate_bottom_length/2.0, -support_plate_bottom_height/2.0);
+		Hep3Vector box_center_support_plate_local;
+		if(half == "bottom") {
+			box_center_support_plate_local = new BasicHep3Vector(support_plate_bottom_width/2.0, support_plate_bottom_length/2.0, -1.0 * support_plate_bottom_height/2.0);
+		} else {
+			box_center_support_plate_local = new BasicHep3Vector(support_plate_bottom_width/2.0, support_plate_bottom_length/2.0,  support_plate_bottom_height/2.0);
+		}
 		
 		//translate to the mother coordinate system
 		Hep3Vector box_center_support = trans_support_plate_to_support.transformed(box_center_support_plate_local);
@@ -785,7 +1123,6 @@
 		double module_box_length = -99999.9;
 		double module_box_height = -99999.9;
 		double module_box_width = -99999.9;
-		Hep3Vector box_dim_local;
 		if( layer >=1 && layer <=3 ) {
 			module_box_length = this.module_box_L13_length;
 			module_box_height = this.module_box_L13_height;
@@ -1330,8 +1667,29 @@
 		return layer;
 	}
 
-	
 
+	private String getHalfFromName(String name) {
+		String half = "";
+		if(name.contains("_bottom")) {
+			half = "bottom";
+		}
+		if(name.contains("_top")) {
+			// check that both sides are not found
+			if(half.equals("bottom")) {
+				print("found both halfs from name  " + name);
+				System.exit(1);
+			} else {
+				half = "top";
+			}
+		}
+		if( half.isEmpty()) {
+			print("found no half from " + name);
+			System.exit(1);
+		}
+		return half;
+	}
+
+
 	private void makeHalfModuleComponentSensor(VolWrapper halfModuleWrap, 
 			Hep3Vector ball_pos_sensor_local, Hep3Vector vee_pos_sensor_local, Hep3Vector flat_pos_sensor_local, 
 			LCDD lcdd, SensitiveDetector sens) throws JDOMException {
@@ -1899,6 +2257,86 @@
 
 
 	
+	
+
+	private void makeBeamPlane(VolWrapper trackingWrap, Hep3Vector ball_pos_base_plate, Hep3Vector vee_pos_base_plate,Hep3Vector flat_pos_base_plate, LCDD lcdd, SensitiveDetector sens) throws JDOMException {
+	
+	
+	if(_debug) {
+		print("--- makeBeamPlane ----");
+		
+	}
+	
+	// create the coordinate system of the beam plane in the tracking volume
+	// since this is a dummy volume it is based on the position of the base plate coordinate system
+	// width - u
+	// length - v
+	// thickness - w
+	Hep3Vector ball_pos_beamplane = ball_pos_base_plate;
+	Hep3Vector vee_pos_beamplane = vee_pos_base_plate; 
+	Hep3Vector flat_pos_beamplane = flat_pos_base_plate;		
+	CoordSysDef beamplane_coord = new CoordSysDef(ball_pos_beamplane, vee_pos_beamplane, flat_pos_beamplane);		
+	Transform3D trans_beamplane_to_tracking = getTransformation(beamplane_coord);
+	
+	String volName = "beamPlaneVol";
+	Box box = new Box(volName + "Box", base_width, base_length, beamPlaneThickness);
+	lcdd.add(box);
+	Volume volume = new Volume(volName + "_volume", box, lcdd.getMaterial("Vacuum"));
+	
+	
+	if(_debug) {
+		print(String.format("ball_pos_beamplane %s", ball_pos_beamplane.toString()));
+		print(String.format("vee_pos_beamplane %s", vee_pos_beamplane.toString()));
+		print(String.format("flat_pos_beamplane %s", flat_pos_beamplane.toString()));
+		print(String.format("beamplane_coord:\n%s", beamplane_coord.toString()));
+	}
+
+	
+	// Find distance to center in the local coordinate system 
+	Hep3Vector box_center_base_local = new BasicHep3Vector(base_width/2.0, base_length/2.0, beamPlaneThickness/2.0);
+	
+	//translate to the mother coordinate system
+	Hep3Vector box_center_base = trans_beamplane_to_tracking.transformed(box_center_base_local);
+	
+	if(_debug) {
+		print(String.format("box_center_base_local  %s", box_center_base_local.toString()));
+		print(String.format("box_center_base        %s", box_center_base.toString()));
+	}
+	
+	// Create the LCDD position
+	Position pos = new Position(volName + "_position",box_center_base.x(), box_center_base.y(), box_center_base.z());
+	
+	//Find LCDD Euler rotation angles from coordinate system unit vectors
+	Hep3Vector lcdd_rot_angles = getEulerAngles(beamplane_coord.v, beamplane_coord.w, new BasicHep3Vector(0,1,0),new BasicHep3Vector(0,0,1));
+	Rotation rot = new Rotation(volName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z());
+	lcdd.add(pos);
+	lcdd.add(rot);
+	
+	// Create the physical volume
+	PhysVol basePV = new PhysVol(volume, trackingWrap.vol, pos, rot);
+	if(_debug) {
+    	 print("Created physical vomume " + basePV.getName());
+     }
+	
+	
+     
+     volume.setVisAttributes(lcdd.getVisAttributes("BeamPlaneVis"));
+	
+    
+	
+     lcdd.add(volume);
+	
+	
+	
+	
+	}
+	
+	
+	
+	
+	
+	
+	
 	private void makeExample(LCDD lcdd, SensitiveDetector sens) throws JDOMException {
 	
 	
@@ -1976,43 +2414,7 @@
 	
 	
 	
-	/*
 	
-	// Find distance to center in the local coordinate system 
-	Hep3Vector box_center_base_local = new BasicHep3Vector(base_width/2.0, base_length/2.0, base_height/2.0);
-	
-	Position pos = new Position(volName + "_position",0,0,0);
-	
-	
-	//org.apache.commons.math3.geometry.euclidean.threed.Vector3D u_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(u.v());
-	//org.apache.commons.math3.geometry.euclidean.threed.Vector3D v_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(v.v());
-	//org.apache.commons.math3.geometry.euclidean.threed.Vector3D u_prime_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(u_prime.v());
-	//org.apache.commons.math3.geometry.euclidean.threed.Vector3D v_prime_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(v_prime.v());
-	//org.apache.commons.math3.geometry.euclidean.threed.Vector3D u_3D = new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(1,0,0);
-	//org.apache.commons.math3.geometry.euclidean.threed.Rotation rot = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(u_3D,v_3D,u_prime_3D,v_prime_3D);
-	//double res[] = rot.getAngles(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ);
-	
-	//org.apache.commons.math3.geometry.euclidean.threed.Rotation rot_cardan = new org.apache.commons.math3.geometry.euclidean.threed.Rotation(org.apache.commons.math3.geometry.euclidean.threed.RotationOrder.XYZ,Math.PI/4.0,0,0);
-	
-	
-	//Find LCDD Euler rotation angles from coordinate system unit vectors
-	Hep3Vector lcdd_rot_angles = new BasicHep3Vector(0,0,0); 
-	getEulerAngles(new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0), new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0));
-	//Hep3Vector lcdd_rot_angles = getEulerAngles(new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0), new BasicHep3Vector(1,0,0),new BasicHep3Vector(0,1,0));
-	//Rotation rot = new Rotation(volName + "_rotation",lcdd_rot_angles.x(), lcdd_rot_angles.y(), lcdd_rot_angles.z());
-	//Rotation rot = new Rotation(volName + "_rotation",0,Math.PI/4.0,Math.PI/2.0);
-	Rotation rot = new Rotation(volName + "_rotation",0,0,0);
-	lcdd.add(pos);
-	lcdd.add(rot);
-	
-	// Create the physical volume
-	PhysVol basePV = new PhysVol(baseVolume, lcdd.pickMotherVolume(this), pos, rot);
-
-	
-	lcdd.add(baseVolume);
-	
-	*/
-	
 	}
 	
 	

projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector
HPSTestRunTracker2014.xml 3161 -> 3162
--- projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml	2014-06-27 05:35:36 UTC (rev 3161)
+++ projects/lcsim/trunk/detector-framework/src/test/resources/org/lcsim/geometry/subdetector/HPSTestRunTracker2014.xml	2014-07-01 01:07:35 UTC (rev 3162)
@@ -30,18 +30,19 @@
   <display>
 	
     <vis name="SensorVis" alpha="1.0" r="1.0" g="0.0" b="0.0" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="true"/>
-    <vis name="CarbonFiberVis" alpha="1.0" r="0.88" g="0.88" b="0.88" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="true"/>
-    <vis name="KaptonVis" alpha="1.0" r="0.91" g="0.77" b="0.06" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="true"/>
-    <vis name="HybridVis" alpha="1.0" r="0.0" g="1.0" b="0" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="true"/>
-    <vis name="HalfModuleVis" alpha="1.0" r="1.0" g="1.0" b="1.0" drawingStyle="wireframe" lineStyle="dashed" showDaughters="true" visible="true"/>
-    <vis name="ColdBlockVis" alpha="1.0" r="1.0" g="0.0" b="0.0" drawingStyle="wireframe" lineStyle="dashed" showDaughters="true" visible="true"/>
-    <vis name="ModuleVis" alpha="1.0" r="1.0" g="1.0" b="1.0" drawingStyle="wireframe" lineStyle="dotted" showDaughters="true" visible="true"/>
-    <vis name="SupportPlateVis" alpha="1.0" r="0.75" g="0.73" b="0.75" drawingStyle="solid" lineStyle="dashed" showDaughters="true" visible="true"/>
+    <vis name="CarbonFiberVis" alpha="1.0" r="0.88" g="0.88" b="0.88" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="false"/>
+    <vis name="KaptonVis" alpha="1.0" r="0.91" g="0.77" b="0.06" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="false"/>
+    <vis name="HybridVis" alpha="1.0" r="0.0" g="1.0" b="0" drawingStyle="wireframe" lineStyle="unbroken" showDaughters="true" visible="false"/>
+    <vis name="HalfModuleVis" alpha="1.0" r="1.0" g="1.0" b="1.0" drawingStyle="wireframe" lineStyle="dashed" showDaughters="true" visible="false"/>
+    <vis name="ColdBlockVis" alpha="1.0" r="0.75" g="0.73" b="0.75" drawingStyle="solid" lineStyle="dashed" showDaughters="true" visible="true"/>
+    <vis name="ModuleVis" alpha="1.0" r="1.0" g="1.0" b="1.0" drawingStyle="wireframe" lineStyle="dotted" showDaughters="true" visible="false"/>
+    <vis name="SupportPlateVis" alpha="1.0" r="0.45" g="0.45" b="0.45" drawingStyle="solid" lineStyle="dashed" showDaughters="true" visible="true"/>
     <vis name="SupportVolumeVis" alpha="1.0" r="0.75" g="0.73" b="0.75" drawingStyle="wireframe" lineStyle="dashed" showDaughters="true" visible="true"/>
-    <vis name="BasePlateVis" alpha="1.0" r="0.75" g="0.73" b="0.75" drawingStyle="wireframe" lineStyle="dashed" showDaughters="true" visible="true"/>
+    <vis name="BasePlateVis" alpha="1.0" r="0.35" g="0.35" b="0.35" drawingStyle="solid" lineStyle="dashed" showDaughters="true" visible="true"/>
     <vis name="LayerVis" alpha="0.0" r="0.0" g="0.0" b="1.0" drawingStyle="wireframe" showDaughters="true" visible="false"/>
     <vis name="ComponentVis" alpha="0.0" r="0.0" g="0.2" b="0.4" drawingStyle="solid" showDaughters="false" visible="false"/>
-	
+	<vis name="BeamPlaneVis" alpha="1.0" r="1.0" g="1.0" b="1.0" drawingStyle="solid" lineStyle="unbroken" showDaughters="false" visible="true"/>
+    
   </display>
   
   <detectors>
SVNspam 0.1


Use REPLY-ALL to reply to list

To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1