From 2b4ad3ed3fe76604fce1f4c4d82c58adf02cf711 Mon Sep 17 00:00:00 2001
From: Marshall Scott <mbscott@anl.gov>
Date: Fri, 26 Mar 2021 15:15:20 -0400
Subject: [PATCH] Working on ci_GEM, volume issue

---
 ci_GEM.xml     |  4 ++--
 src/ci_GEM.cpp | 29 +++++++++++++----------------
 2 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/ci_GEM.xml b/ci_GEM.xml
index 9a03732..4a3e867 100644
--- a/ci_GEM.xml
+++ b/ci_GEM.xml
@@ -45,7 +45,7 @@
   <!-- change this -->
   <comment>Common Generic visualization attributes</comment>
   <display>
-    <vis name="ci_GEMVis" alpha="0.4"  r= "0.1"  g="0.0"  b="0.1"  showDaughters="true" visible="true"/>
+    <vis name="ci_GEMVis"   r= "0.8"  g="0.4"  b="0.3" alpha="0.8" showDaughters="true" visible="true"/>
   </display>
 
   <!-- Define detector -->
@@ -55,7 +55,7 @@
     </comment>
     <detector id="ci_GEM_id" name="ci_GEM" type="ci_GEM" insideTrackingVolume="false" vis="ci_GEMVis">
 	    <material name="Ar10CO2"/>  <!-- G4_Galactic -->	    
-      <dimensions rmin="ci_GEM_rin" rmax="ci_GEM_rout" sizez="ci_GEM_sizez" delta="ci_GEM_shiftz"	posz="ci_GEM_posz" posx="ci_GEM_posx" nlayers="ci_GEM_nlayers"/>
+      <dimensions rmin="ci_GEM_rin" rmax="ci_GEM_rout" sizez="ci_GEM_sizez" delta="ci_GEM_shiftz"	z="ci_GEM_posz" x="ci_GEM_posx" nlayers="ci_GEM_nlayers"/>
       <layer id="0" z="-sizez * 0.5 + (5 + 3. * id) * cm" inner_r="rmin + (1. + 0.5 * id) * cm" outer_r="rmax + (-25. + 2. * id) * cm" dz="1 * cm" />
       <layer id="1" z="-sizez * 0.5 + (5 + 3. * id) * cm" inner_r="rmin + (1. + 0.5 * id) * cm" outer_r="rmax + (-25. + 2. * id) * cm" dz="1 * cm" />
       <layer id="2" z="-sizez * 0.5 + (5 + 3. * id) * cm" inner_r="rmin + (1. + 0.5 * id) * cm" outer_r="rmax + (-25. + 2. * id) * cm" dz="1 * cm" />
diff --git a/src/ci_GEM.cpp b/src/ci_GEM.cpp
index 9751d97..c806696 100644
--- a/src/ci_GEM.cpp
+++ b/src/ci_GEM.cpp
@@ -16,37 +16,34 @@ static Ref_t createDetector(Detector& desc, xml_h handle, SensitiveDetector sens
   double ROut   = dims.rmax();  // Outer radius
   double RIn    = dims.rmin();  // Inner radius
   double ShiftZ = dims.delta();
-  double PosX   = dims.posx();
-  double PosZ   = dims.posz();
+  double X      = dims.x();
+  double Z      = dims.z();
   int Nlayers   = dims.nlayers();
   Material mat  = desc.material(detElem.materialStr());
-
-  Tube envelope(RIn, ROut, SizeZ, 0, 360 * deg);
-  //Volume envelopeVol(detName + "_envelope", envelope, det.;
   
   Tube   ci_GEM_GVol_Solid(RIn, ROut, SizeZ / 2., 0., 360 * deg);
   Volume detVol("ci_GEM_GVol_Logic", ci_GEM_GVol_Solid, mat);
+  detVol.setVisAttributes(desc.visAttributes(detElem.visStr()));
 
+  DetElement   det(detName, detID);
+  Volume       motherVol = desc.pickMotherVolume(det);
+  Transform3D  tr(RotationZYX(0., 0., 0.), Position(0., 0., ShiftZ));
+  PlacedVolume detPV = motherVol.placeVolume(detVol, tr);
+  
   
+  //Adding layers to placed volume
   for (cml_coll_t c(detElem, _U(layer)); c; c++)
   {
   	xml_comp_t x_layer = c;
   	string layer_name = detName + _toString(c.id(), "_layer%d");
   	Volume layer_vol(layer_name, Tube(c.rmin(), c.rmax(), c.z() ), mat );
-  	Position layer_pos(0, 0, fnz);
-  	pv = envelopeVol.placeVolume(layer_vol, layer_pos);
-  	pv.addPhysVolID("layer", c.id() );
+  	layer_vol.
+  	Position layer_pos(0, 0, 0);
+  	detPV.placeVolume(layer_vol, layer_pos);
   }
 
-
-
-  detVol.setVisAttributes(desc.visAttributes(detElem.visStr()));
-
-  DetElement   det(detName, detID);
-  Volume       motherVol = desc.pickMotherVolume(det);
-  Transform3D  tr(RotationZYX(0., 0., 0.), Position(0., 0., ShiftZ));
-  PlacedVolume detPV = motherVol.placeVolume(envelopeVol, tr);
   det.setPlacement(detPV);
+
   return det;
 }
 // clang-format off
-- 
GitLab