Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Whitney Armstrong, Wouter Deconinck
0003 
0004 //==========================================================================
0005 //
0006 //      <detector name ="DetName" type="Beampipe" >
0007 //      <layer id="#(int)" inner_r="#(double)" outer_z="#(double)" >
0008 //      <slice material="string" thickness="#(double)" >
0009 //      </layer>
0010 //      </detector>
0011 //==========================================================================
0012 #include "DD4hep/DetFactoryHelper.h"
0013 #include "DD4hep/Printout.h"
0014 #include "TMath.h"
0015 #include <XML/Helper.h>
0016 
0017 using namespace std;
0018 using namespace dd4hep;
0019 
0020 /** \addtogroup beamline Beamline Instrumentation
0021  */
0022 
0023 /** \addtogroup IRChamber Interaction Region Vacuum Chamber.
0024  * \brief Type: **IRChamber**.
0025  * \ingroup beamline
0026  *
0027  *
0028  * \code
0029  *   <detector>
0030  *   </detector>
0031  * \endcode
0032  *
0033  */
0034 static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector /* sens */) {
0035 
0036   using namespace ROOT::Math;
0037   xml_det_t x_det = e;
0038   string det_name = x_det.nameStr();
0039   DetElement sdet(det_name, x_det.id());
0040   Assembly assembly(det_name + "_assembly");
0041   Material m_Steel  = det.material("StainlessSteel");
0042   Material m_Vacuum = det.material("Vacuum");
0043   string vis_name   = x_det.visStr();
0044 
0045   xml::Component box_dim = x_det.child(_Unicode(dimensions));
0046   double height          = box_dim.attr<double>(_Unicode(height));
0047   double width           = box_dim.attr<double>(_Unicode(width));
0048   double depth           = box_dim.attr<double>(_Unicode(depth));
0049 
0050   xml::Component col_XS = x_det.child(_Unicode(collimator));
0051   double colHeight      = col_XS.attr<double>(_Unicode(height));
0052   double colWidth       = col_XS.attr<double>(_Unicode(width));
0053   double colXOff        = col_XS.attr<double>(_Unicode(xOff));
0054 
0055   xml::Component box_place = x_det.child(_Unicode(placement));
0056   double zOff              = box_place.attr<double>(_Unicode(z));
0057 
0058   Box box_steel(width, height, depth);
0059   Box box_vacuum(colWidth, colHeight, depth);
0060 
0061   Volume v_steel("v_steel", box_steel, m_Steel);
0062   Volume v_vacuum("v_vacuum", box_vacuum, m_Vacuum);
0063 
0064   sdet.setAttributes(det, v_steel, x_det.regionStr(), x_det.limitsStr(), vis_name);
0065 
0066   assembly.placeVolume(v_steel, Position(0, 0, 0));
0067   v_steel.placeVolume(v_vacuum, Position(colXOff, 0, 0));
0068 
0069   // -----------------------------
0070   // final placement
0071   auto pv_assembly = det.pickMotherVolume(sdet).placeVolume(
0072       assembly, Transform3D(RotationZYX(0.0, 0.0, 0.0), Position(0.0, 0.0, zOff)));
0073   pv_assembly.addPhysVolID("system", sdet.id()).addPhysVolID("barrel", 1);
0074   sdet.setPlacement(pv_assembly);
0075   assembly->GetShape()->ComputeBBox();
0076   return sdet;
0077 }
0078 
0079 DECLARE_DETELEMENT(BackwardsCollimator, create_detector)