From 57cf00b91620e225d00a54f57f80c163009eb916 Mon Sep 17 00:00:00 2001
From: Marshall Scott <mbscott@anl.gov>
Date: Mon, 5 Apr 2021 13:56:19 -0400
Subject: [PATCH] Changed .xml files and ci_GEM.cpp

---
 compact/ci_GEM.xml      | 61 +++++++++++++++++++++++++++++++++++++++++
 compact/definitions.xml | 38 +++++++++++++++++++++++--
 compact/display.xml     |  3 ++
 src/ci_GEM.cpp          | 16 +++++------
 4 files changed, 106 insertions(+), 12 deletions(-)
 create mode 100644 compact/ci_GEM.xml

diff --git a/compact/ci_GEM.xml b/compact/ci_GEM.xml
new file mode 100644
index 0000000..7e88f36
--- /dev/null
+++ b/compact/ci_GEM.xml
@@ -0,0 +1,61 @@
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" 
+       xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+>
+
+  <!-- Some information about detector  -->
+  <info name="Central Ion GEM" title="Central Ion GEM"
+        author="Marshall Scott"
+        url="https://eicweb.phy.anl.gov/EIC/detectors/reference_detector.git"
+        status="development"
+        version="v1 2021-03-23">
+    <comment>Central Ion GEM</comment>        
+  </info>
+
+  <!-- Use DD4hep elements and materials definitions -->
+  <includes>
+  </includes>
+
+  <!-- Define the dimensions of the world volume
+  <define>
+    <constant name="ci_GEM_id"      value="1">
+    <constant name="ci_GEM_rin"     value="10 * cm">
+    <constant name="ci_GEM_rout"    value="95 * cm">
+    <constant name="ci_GEM_sizez"   value="30 * cm">
+    <constant name="ci_GEM_shiftz"  value="0 * cm">
+    <constant name="ci_GEM_posz"    value="0 * cm">
+    <constant name="ci_GEM_posx"    value="0 * cm">
+    <constant name="ci_GEM_nlayers" value="8">
+  </define>
+  -->
+
+   <limits>
+  </limits>
+
+  <regions>
+  </regions>
+
+  <display>
+  </display>
+
+  <!-- Define detector -->
+  <detectors>
+    <comment>
+      Central Ion GEM
+    </comment>
+    <detector id="ci_GEM_id" name="ci_GEM" type="ci_GEM" insideTrackingVolume="false" vis="ci_GEMVis">
+	    <material name="Ar10CO2"/>  
+      <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" />
+      <layer id="3" 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="4" 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="5" 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="6" 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="7" 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" />
+    </detector>
+  </detectors>
+
+  <plugins>
+  </plugins>
\ No newline at end of file
diff --git a/compact/definitions.xml b/compact/definitions.xml
index 9c26984..032c7fc 100644
--- a/compact/definitions.xml
+++ b/compact/definitions.xml
@@ -25,7 +25,7 @@
       endcapP/endcapN are the endcaps at positive/negative z values. 
       See https://acts.readthedocs.io/en/latest/plugins/dd4hep.html for more details.
 
-      The tracking geometry needs to beconstructed from cylinders from the inside out. For this reason
+      The tracking geometry needs to be constructed from cylinders from the inside out. For this reason
       each layer needs its own subsystem assembly. This increases the number of top level system IDs. 
       For example the silicon tracker needs 3 IDs for each area (endcap+barrel+endcap) and a subassembly for each
       layer. Therefore it needs a minimum of 20 IDs. Therefore we will allocate blocks of ~25 for each major subsystem.
@@ -124,7 +124,7 @@
 
     <comment> 
     ===================
-    (75-99 Reserved IDs
+    (75-99) Reserved IDs
     ===================
 
     Unused IDs: 75-99 
@@ -153,7 +153,7 @@
 
     <comment> 
       =====================================
-      (110-119Hadronic Calorimeter
+      (110-119) Hadronic Calorimeter
       =====================================
 
       HCal     subsystem  ID:  110
@@ -467,6 +467,38 @@
     <constant name="ce_MRICHLength" value="15*cm"/>
     <constant name="ce_MRICHZMin" value="-EcalEndcap_zmin+10.*cm"/>
 
+    <comment>
+      --------------------------
+      Central Ion HCal Parameters
+      --------------------------
+    </comment>
+    <constant name="ci_HCAL_id"      value="1"/>
+    <constant name="ci_HCAL_rin"     value="0 * cm"/>
+    <constant name="ci_HCAL_rout"    value="300 * cm"/>
+    <constant name="ci_HCAL_sizez"   value="160 * cm"/>
+    <constant name="ci_HCAL_shiftz"  value="5 * cm"/>
+    <constant name="ci_HCAL_posz"    value="0 * cm"/>
+   
+    <constant name="ci_HCAL_nlayers"       value="20"/>
+    <constant name="ci_HCAL_lay_rin"       value="80 * cm"/>
+    <constant name="ci_HCAL_lay_rout"      value="ci_HCAL_rout - 1 * cm"/>
+    <constant name="ci_HCAL_lay_thickness" value="2* cm"/>
+    <constant name="ci_HCAL_lay_gapz"      value="2* cm"/>
+
+    <comment>
+      --------------------------
+      Central Ion GEM Parameters
+      --------------------------
+    </comment>
+    <constant name="ci_GEM_id"      value="1">
+    <constant name="ci_GEM_rin"     value="10 * cm">
+    <constant name="ci_GEM_rout"    value="95 * cm">
+    <constant name="ci_GEM_sizez"   value="30 * cm">
+    <constant name="ci_GEM_shiftz"  value="0 * cm">
+    <constant name="ci_GEM_posz"    value="0 * cm">
+    <constant name="ci_GEM_posx"    value="0 * cm">
+    <constant name="ci_GEM_nlayers" value="8">
+
 
 
 
diff --git a/compact/display.xml b/compact/display.xml
index ae6af1b..f9d3148 100644
--- a/compact/display.xml
+++ b/compact/display.xml
@@ -50,6 +50,9 @@
 
     <vis name="cb_SolenoidVis" 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"/>
+    <vis name="ci_HCALVis"  r= "0.6"  g="0"  b="0.6" alpha="1.0" showDaughters="true" visible="true"/>
+
     <comment>
       Deprecated colors.
     </comment>
diff --git a/src/ci_GEM.cpp b/src/ci_GEM.cpp
index c71bb05..60cb1d0 100644
--- a/src/ci_GEM.cpp
+++ b/src/ci_GEM.cpp
@@ -75,24 +75,22 @@ static Ref_t createDetector(Detector& desc, xml_h handle, SensitiveDetector sens
   
   //Adding layers to placed volume
   xml_comp_t x_layer = detElem.child(_U(layer));
-  for (int layerNum = 0; layerNum < Nlayers; layerNum++){
-  	std::string layer_name = detName + _toString(layerNum, "_layer%d");
+  for (int lNum = 0; lNum < Nlayers; lNum++){
+  	std::string layer_name = detName + _toString(lNum, "_layer%d");
   	double lrmin, lrmax, lz;
-  	lrmin = RIn + (1.0 + 0.5 * layerNum) * dd4hep::cm;
-  	lrmax = ROut + (-25.0 + 2.0 * layerNum) * dd4hep::cm;
-  	lz    = SizeZ * 0.5 + (5.0 + 3. * layerNum) * dd4hep::cm; 
+  	lrmin = RIn + (1.0 + 0.5 * lNum) * dd4hep::cm;
+  	lrmax = ROut + (-25.0 + 2.0 * lNum) * dd4hep::cm;
+  	lz    = SizeZ * 0.5 + (5.0 + 3. * lNum) * dd4hep::cm; 
   	Volume layer_vol(layer_name, Tube(lrmin, lrmax, 1.0 * dd4hep::cm), mat);
   	Position layer_pos(0, 0, lz);
   	DetElement layer(det, layer_name, detID);
-  	layer.setVisAttributes(desc.visAttributes(detElem.visStr()));
+  	layer_vol.setVisAttributes(desc.visAttributes(detElem.visStr()));
   	//layer.setAttributes(desc, layer_vol, desc.region(), desc.limits(), );//(region, limits, visable).
   	PlacedVolume layer_phv = detVol.placeVolume(layer_vol, layer_pos);
-  	layer_phv.addPhysVolID("layer", layerNum);
+  	layer_phv.addPhysVolID("layer", lNum);
   	layer.setPlacement(layer_phv);
-  	layerNum++;
   }
 
-  DetElement   det(detName, detID);
   return det;
 }
 // clang-format off
-- 
GitLab