From 98391417970d566dae5d546aa0d3b2fe9fe98c6e Mon Sep 17 00:00:00 2001 From: Marshall Scott <mbscott@anl.gov> Date: Wed, 14 Apr 2021 13:23:41 -0400 Subject: [PATCH] First draft fi_B0_EMCAL --- compact/definitions.xml | 19 +++++++++ compact/display.xml | 2 + compact/fi_B0_EMCAL.xml | 46 +++++++++++++++++++++ src/fi_B0_EMCAL.cpp | 92 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+) create mode 100644 compact/fi_B0_EMCAL.xml create mode 100644 src/fi_B0_EMCAL.cpp diff --git a/compact/definitions.xml b/compact/definitions.xml index 542083e..d290ddf 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -653,5 +653,24 @@ <constant name="ci_GEM_posx" value="0 * cm"/> <constant name="ci_GEM_nlayers" value="8"/> + <comment> + -------------------------- + Forward Ion B0 EMCAL + -------------------------- + will move later + </comment> + <constant name="fi_B0_EMCAL_ID" value="500"/> + <constant name="fi_B0_EMCAL_y_length" value="4 * cm"/> + <constant name="fi_B0_EMCAL_x_length" value="4 * cm"/> + <constant name="fi_B0_EMCAL_sizez" value="40 * cm"/> + <constant name="fi_B0_EMCAL_rmin" value="7 * cm"/> + <constant name="fi_B0_EMCAL_rmax" value="10 * cm"/> + <constant name="fi_B0_EMCAL_z" value="0 * cm"/> + <constant name="fi_B0_EMCAL_Gap" value="0.01 * mm"/> + <constant name="fi_B0_EMCAL_x_Shift" value="-35 * cm"/> + <constant name="fi_B0_EMCAL_angle" value="0.05"/><comment> not used in .h file </comment> + + + </define> diff --git a/compact/display.xml b/compact/display.xml index d0733f6..4a11902 100644 --- a/compact/display.xml +++ b/compact/display.xml @@ -59,6 +59,8 @@ <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"/> + <vis name="fi_B0_EMCALVis" r= "0.1" g="1.0" b="0.9" alpha="1.0" showDaughters="true" visible="true"/> + <comment> Deprecated colors. </comment> diff --git a/compact/fi_B0_EMCAL.xml b/compact/fi_B0_EMCAL.xml new file mode 100644 index 0000000..213ed47 --- /dev/null +++ b/compact/fi_B0_EMCAL.xml @@ -0,0 +1,46 @@ +<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="Forward Ion B0 EMCAL" title="Forward Ion B0 EMCAL" + author="Marshall Scott" + url="https://eicweb.phy.anl.gov/EIC/detectors/reference_detector.git" + status="development" + version="v1 2021-04-14"> + <comment>Forward Ion B0 EMCAL</comment> + </info> + + <includes> + </includes> + + <limits> + </limits> + + <regions> + </regions> + + <display> + </display> + + <!-- Define detector --> + <detectors> + <comment> + Forward Ion B0 EMCAL + </comment> + <detector id="fi_B0_EMCAL_ID" name="fi_B0_EMCAL" type="fi_B0_EMCAL" insideTrackingVolume="false" vis="fi_B0_EMCALVis" readout="fi_B0_EMCAL_Hits"> + <material name="PbWO4"/> + <dimensions length="fi_B0_EMCAL_y_length" width="fi_B0_EMCAL_x_length" z_length="fi_B0_EMCAL_sizez" x_offset="fi_B0_EMCAL_x_Shift" rmin="fi_B0_EMCAL_rmin" rmax="fi_B0_EMCAL_rmax" z="fi_B0_EMCAL_z" gap="fi_B0_EMCAL_Gap" angle="fi_B0_EMCAL_angle"/> + </detector> + </detectors> + <readouts> + <readout name="fi_B0_EMCAL_Hits"> + <segmentation type="CartesianGridXY" grid_size_x="1.0*mm" grid_size_y="1.0*mm" /> + <id>system:8,layer:8,x:32:-16,y:-16</id> + </readout> + </readouts> + + + <plugins> + </plugins> +</lccdd> diff --git a/src/fi_B0_EMCAL.cpp b/src/fi_B0_EMCAL.cpp new file mode 100644 index 0000000..add7217 --- /dev/null +++ b/src/fi_B0_EMCAL.cpp @@ -0,0 +1,92 @@ +#include <XML/Helper.h> +/////////////////////////// +// Central Ion GEM +/////////////////////////// + +using namespace dd4hep; + +static Ref_t createDetector(Detector& desc, xml_h handle, SensitiveDetector sens) +{ + + xml::DetElement detElem = handle; + std::string detName = detElem.nameStr(); + int detID = detElem.id(); + xml::Component dims = detElem.dimensions(); + double RIn = dims.rmin(); + double ROut = dims.rmax(); + double SizeZ = dims.z_length(); + double X_Shift = dims.x_offset(); + double X_length = dims.width(); + double Y_length = dims.length(); + double Z = dims.z(); + double Angle = dims.angle(); + double Gap = dims.gap(); + Material pbw04 = desc.material("PbWO4"); + Material vacuum = desc.material("Vacuum"); + + //Outer volume + Box fi_B0_EMCAL_Solid(X_length / 2., Y_length / 2., SizeZ / 2.); + Volume envelopeVol("fi_B0_EMCAL_Logic", fi_B0_EMCAL_Solid, pbw04); + envelopeVol.setVisAttributes(desc.visAttributes(detElem.visStr())); + + // Crystals + double y_C = 0 * dd4hep::cm; + double x_C = 0 * dd4hep::cm; + int k = -1; + char* abname; + + for (int j = 0; j < 50; j++) { + y_C -= Y_length + Gap; + x_C = (X_length + Gap) * 0.5; + sens.setType("calorimeter"); + + for (int i = 0; i < 50; i++) { + double R = sqrt(x_C * x_C + y_C * y_C); + if (R < ROut - X_length + Gap && R > RIn) { + k++; + std::sprintf(abname, "fi_B0_EMCAL_%d", k); + Volume crystalVol1(abname, fi_B0_EMCAL_Solid, pbw04); + crystalVol1.setSensitiveDetector(sens); + Transform3D tr1(RotationZYX(0,0,0), Position(x_C + X_Shift, y_C, Z)); + PlacedVolume cry1 = envelopeVol.placeVolume(crystalVol1, tr1); + cry1.addPhysVolID("crystal", k); + + k++; + std::sprintf(abname, "fi_B0_EMCAL_%d", k); + Volume crystalVol2(abname, fi_B0_EMCAL_Solid, pbw04); + crystalVol2.setSensitiveDetector(sens); + Transform3D tr2(RotationZYX(0,0,0), Position(-x_C + X_Shift, y_C, Z)); + PlacedVolume cry2 = envelopeVol.placeVolume(crystalVol2, tr2); + cry2.addPhysVolID("crystal", k); + + k++; + std::sprintf(abname, "fi_B0_EMCAL_%d", k); + Volume crystalVol3(abname, fi_B0_EMCAL_Solid, pbw04); + crystalVol3.setSensitiveDetector(sens); + Transform3D tr3(RotationZYX(0,0,0), Position(x_C + X_Shift, -y_C, Z)); + PlacedVolume cry3 = envelopeVol.placeVolume(crystalVol3, tr3); + cry3.addPhysVolID("crystal", k); + + k++; + std::sprintf(abname, "fi_B0_EMCAL_%d", k); + Volume crystalVol4(abname, fi_B0_EMCAL_Solid, pbw04); + crystalVol4.setSensitiveDetector(sens); + Transform3D tr4(RotationZYX(0,0,0), Position(-x_C + X_Shift, -y_C, Z)); + PlacedVolume cry4 = envelopeVol.placeVolume(crystalVol4, tr4); + cry4.addPhysVolID("crystal", k); + } + x_C += X_length + Gap; + } + } + + DetElement det(detName, detID); + Volume motherVol = desc.pickMotherVolume(det); + Transform3D tr(RotationZYX(0,0,0), Position(0, 0, 0)); + PlacedVolume detPV = motherVol.placeVolume(envelopeVol, tr); + detPV.addPhysVolID("system", detID); + det.setPlacement(detPV); + + return det; +} +// clang-format off +DECLARE_DETELEMENT(fi_B0_EMCAL, createDetector) -- GitLab