From a76a641aa8675624299307be92bd0a444e7cf677 Mon Sep 17 00:00:00 2001 From: Marshall Scott <mbscott@anl.gov> Date: Mon, 29 Mar 2021 13:18:02 -0400 Subject: [PATCH] Testing .cpp with w/o using xml --- ci_GEM.xml | 5 ----- src/ci_GEM.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/ci_GEM.xml b/ci_GEM.xml index 4a3e867..755a7c9 100644 --- a/ci_GEM.xml +++ b/ci_GEM.xml @@ -20,11 +20,6 @@ <!-- Define the dimensions of the world volume --> <define> - <constant name="world_side" value="50*m"/> - <constant name="world_x" value="world_side"/> - <constant name="world_y" value="world_side"/> - <constant name="world_z" value="world_side"/> - <constant name="ci_GEM_id" value="1"> <constant name="ci_GEM_rin" value="10 * cm"> <constant name="ci_GEM_rout" value="95 * cm"> diff --git a/src/ci_GEM.cpp b/src/ci_GEM.cpp index c806696..5fb1a15 100644 --- a/src/ci_GEM.cpp +++ b/src/ci_GEM.cpp @@ -7,6 +7,7 @@ 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(); @@ -20,15 +21,17 @@ static Ref_t createDetector(Detector& desc, xml_h handle, SensitiveDetector sens double Z = dims.z(); int Nlayers = dims.nlayers(); Material mat = desc.material(detElem.materialStr()); + Material air = desc.material("Air"); Tube ci_GEM_GVol_Solid(RIn, ROut, SizeZ / 2., 0., 360 * deg); - Volume detVol("ci_GEM_GVol_Logic", ci_GEM_GVol_Solid, mat); + Volume detVol("ci_GEM_GVol_Logic", ci_GEM_GVol_Solid, air); 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); + det.setPlacement(detPV); //Adding layers to placed volume @@ -44,6 +47,56 @@ static Ref_t createDetector(Detector& desc, xml_h handle, SensitiveDetector sens det.setPlacement(detPV); + return det; + */ + xml::DetElement detElem = handle; + std::string detName = "ci_GEM"; + int detID = 1; + + xml::Component dims = detElem.dimensions(); + double SizeZ = 30. * dd4hep::cm; // Size in Z direction + double ROut = 95. * dd4hep::cm; // Outer radius + double RIn = 10. * dd4hep::cm; // Inner radius + double ShiftZ = 0. * dd4hep::cm; + double X = 0. * dd4hep::cm; + double Z = 0. * dd4hep::cm; + int Nlayers = 8; + Material mat = desc.material(detElem.materialStr()); + Material air = desc.material("Air"); + + DetElement det(detName, detID); + Volume motherVol = desc.pickMotherVolume(det); + Tube ci_GEM_GVol_Solid(RIn, ROut, SizeZ / 2., 0., 360 * deg); + Volume detVol("ci_GEM_GVol_Logic", ci_GEM_GVol_Solid, air); + PlacedVolume detPV = motherVol.placeVolume(detVol, RotationZYX(0,0,0)); + detPV.addPhysVolID("system", detID); + det.setPlacement(detPV); + + //detVol.setVisAttributes(desc.visAttributes(detElem.visStr())); + + + + + //Adding layers to placed volume + int layerNum = 0; + for (cml_coll_t c(detElem, _U(layer)); c; c++) + { + xml_comp_t x_layer = c; + string layer_name = detName + _toString(layerNum, "_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; + Volume layer_vol(layer_name, Tube(lrmin, lrmax, lz ), mat); + Position layer_pos(0, 0, lz); + DetElement layer(det, layer_name, detID); + //layer.setAttributes(desc, layer_vol, , , );//(region, limits, visable). + PlacedVolume layer_phv = detVol.placeVolume(layer_vol, layer_pos); + layer_phv.addPhysVolID("layer", layerNum); + layer.setPlacement(layer_phv); + layerNum++; + } + return det; } // clang-format off -- GitLab