Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:15:55

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2024 Leszek Kosarzewski
0003 
0004 //==========================================================================
0005 //  Implementation of backward endcap flux return
0006 //--------------------------------------------------------------------------
0007 //  Author: Leszek Kosarzewski (OSU)
0008 //==========================================================================
0009 
0010 #include "DD4hep/DetFactoryHelper.h"
0011 #include "TVector3.h"
0012 #include "XML/Layering.h"
0013 
0014 static dd4hep::Ref_t create_detector(dd4hep::Detector& description, xml_h e,
0015                                      [[maybe_unused]] dd4hep::SensitiveDetector sens) {
0016   xml_det_t x_det      = e;
0017   int det_id           = x_det.id();
0018   std::string det_name = x_det.nameStr();
0019   bool reflect         = x_det.reflect(false);
0020   dd4hep::Material air = description.air();
0021   xml_comp_t x_pos     = x_det.position();
0022   dd4hep::Assembly assembly(det_name);
0023   dd4hep::DetElement sdet(det_name, det_id);
0024   dd4hep::PlacedVolume pv;
0025 
0026   double disksGap = 0.0;
0027 
0028   // Looping through all the different layer sections
0029   for (xml_coll_t xc(x_det, _U(layer)); xc; ++xc) {
0030     xml_comp_t x_layer = xc;
0031 
0032     int layer_id           = x_layer.id();
0033     double layer_rmax      = x_layer.rmax();
0034     double layer_rmin      = x_layer.rmin();
0035     double layer_thickness = x_layer.thickness();
0036     double layer_zpos      = x_layer.zpos();
0037 
0038     dd4hep::Material l_mat = description.material(x_layer.materialStr());
0039 
0040     dd4hep::DetElement disk_ele("disk_ele", layer_id);
0041     dd4hep::Volume disk(x_layer.nameStr(),
0042                         dd4hep::Tube(layer_rmin, layer_rmax, layer_thickness / 2, 0.0, 2.0 * M_PI),
0043                         air);
0044     disk.setVisAttributes(description.visAttributes(x_layer.visStr()));
0045 
0046     dd4hep::Volume halfdisk(
0047         "halfdisk",
0048         dd4hep::Tube(layer_rmin, layer_rmax, layer_thickness / 2, M_PI / 2, M_PI * 3 / 2), l_mat);
0049     halfdisk.setVisAttributes(description.visAttributes(x_layer.visStr()));
0050     dd4hep::PlacedVolume s_phv1 = disk.placeVolume(halfdisk, dd4hep::Position(-disksGap / 2, 0, 0));
0051     s_phv1.addPhysVolID("halfdisk", 0);
0052     dd4hep::PlacedVolume s_phv2 =
0053         disk.placeVolume(halfdisk, dd4hep::Transform3D(dd4hep::RotationZYX(M_PI, 0, 0),
0054                                                        dd4hep::Position(+disksGap / 2, 0, 0)));
0055     s_phv2.addPhysVolID("halfdisk", 1);
0056 
0057     pv = assembly.placeVolume(
0058         disk, dd4hep::Position(0, 0, (reflect ? -1.0 : 1.0) * (layer_thickness / 2 + layer_zpos)));
0059     pv.addPhysVolID("layer", layer_id);
0060     disk_ele.setPlacement(pv);
0061   }
0062 
0063   // Get position and place volume
0064   dd4hep::Position pos(x_pos.x(), x_pos.y(), x_pos.z());
0065   pv = description.pickMotherVolume(sdet).placeVolume(assembly, pos);
0066   sdet.setPlacement(pv);
0067   return sdet;
0068 }
0069 
0070 DECLARE_DETELEMENT(epic_EndcapFluxReturn, create_detector)