From 9dadb1efc6910bfca54037a1b1b4c64dd5d1492d Mon Sep 17 00:00:00 2001 From: myliu <201916234@mail.sdu.edu.cn> Date: Mon, 14 Dec 2020 21:48:12 +0800 Subject: [PATCH] Optimize wire volume --- .../src/driftchamber/DriftChamber.cpp | 66 ++++++++++--------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp b/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp index 48ae890e..97676c5a 100644 --- a/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp +++ b/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp @@ -62,6 +62,10 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, double epsilon = theDetector.constant<double>("Epsilon"); + // - Only keep one chamber +// bool Close_inner_chamber = 1; +// bool Close_outer_chamber = 1; + // ======================================================================= // Detector Construction // ======================================================================= @@ -132,38 +136,36 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, layer_vol.setAttributes(theDetector,x_det.regionStr(),x_det.limitsStr(),x_det.visStr()); // - wire vol -// if(layer_id==0) { + xml_coll_t c(x_det,_U(module)); + xml_comp_t x_module = c; + double module_rmin,module_rmax; + std::string module_name; + if(x_module.id()==0) { + module_rmin = x_module.rmin(); + module_rmax = x_module.rmax(); + module_name = x_module.nameStr(); + } + dd4hep::Tube module_solid(module_rmin,module_rmax,chamber_length*0.5); + dd4hep::Volume module_vol(module_name,module_solid,det_mat); + for(xml_coll_t l(x_module,_U(tubs)); l; ++l) { + xml_comp_t x_tube =l; + double tube_rmin = x_tube.rmin(); + double tube_rmax = x_tube.rmax(); + std::string tube_name = x_tube.nameStr(); + std::string wire_name= module_name + tube_name; + dd4hep::Material tube_mat = theDetector.material(x_tube.materialStr()); + dd4hep::Tube wire_solid(tube_rmin,tube_rmax,chamber_length*0.5); + dd4hep::Volume wire_vol(wire_name,wire_solid,tube_mat); + dd4hep::Transform3D transform_wire(dd4hep::Rotation3D(),dd4hep::Position(0.,0.,0.)); + dd4hep::PlacedVolume wire_phy = module_vol.placeVolume(wire_vol,transform_wire); + } + for(int icell=0; icell< numWire; icell++) { double wire_phi = (icell+0.5)*layer_Phi + offset; - for(xml_coll_t c(x_det,_U(module)); c; ++c) { - xml_comp_t x_module = c; - double module_rmin,module_rmax; - std::string module_name; - if(x_module.id()==0) { - module_rmin = x_module.rmin(); - module_rmax = x_module.rmax(); - module_name = x_module.nameStr(); - } - dd4hep::Tube module_solid(module_rmin,module_rmax,chamber_length*0.5); - std::string Module_name = layer_name + module_name; - dd4hep::Volume module_vol(Module_name,module_solid,det_mat); - for(xml_coll_t l(x_module,_U(tubs)); l; ++l) { - xml_comp_t x_tube =l; - double tube_rmin = x_tube.rmin(); - double tube_rmax = x_tube.rmax(); - std::string tube_name = x_tube.nameStr(); - std::string wire_name= Module_name + _toString(icell,"_%d") + tube_name; - dd4hep::Material tube_mat = theDetector.material(x_tube.materialStr()); - dd4hep::Tube wire_solid(tube_rmin,tube_rmax,chamber_length*0.5); - dd4hep::Volume wire_vol(wire_name,wire_solid,tube_mat); - dd4hep::Transform3D transform_wire(dd4hep::Rotation3D(),dd4hep::Position(0.,0.,0.)); - dd4hep::PlacedVolume wire_phy = module_vol.placeVolume(wire_vol,transform_wire); - } - dd4hep::Transform3D transform_module(dd4hep::Rotation3D(),dd4hep::Position(rmid*std::cos(wire_phi),rmid*std::sin(wire_phi),0.)); - dd4hep::PlacedVolume module_phy = layer_vol.placeVolume(module_vol,transform_module); - } - } -// } + dd4hep::Transform3D transform_module(dd4hep::Rotation3D(),dd4hep::Position(rmid*std::cos(wire_phi),rmid*std::sin(wire_phi),0.)); + dd4hep::PlacedVolume module_phy = layer_vol.placeVolume(module_vol,transform_module); + } + dd4hep::Transform3D transform_layer(dd4hep::Rotation3D(),dd4hep::Position(0.,0.,0.)); dd4hep::PlacedVolume layer_phy = (*current_vol_ptr).placeVolume(layer_vol, transform_layer); layer_phy.addPhysVolID("layer",layer_id); @@ -177,17 +179,21 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, // inner dd4hep::Transform3D transform_inner_chamber(dd4hep::Rotation3D(), dd4hep::Position(0,0,0)); +// if(Close_inner_chamber) { dd4hep::PlacedVolume det_inner_chamber_phy = det_vol.placeVolume(det_inner_chamber_vol, transform_inner_chamber); det_inner_chamber_phy.addPhysVolID("chamber", 0); +// } // outer dd4hep::Transform3D transform_outer_chamber(dd4hep::Rotation3D(), dd4hep::Position(0,0,0)); +// if(Close_outer_chamber) { dd4hep::PlacedVolume det_outer_chamber_phy = det_vol.placeVolume(det_outer_chamber_vol, transform_inner_chamber); det_outer_chamber_phy.addPhysVolID("chamber", 1); +// } // - place in world dd4hep::Transform3D transform(dd4hep::Rotation3D(), dd4hep::Position(0,0,0)); -- GitLab