Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:28:38

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 //
0014 // Specialized generic detector constructor
0015 // 
0016 //  mod.:        P.Kostka LHeD (asymmetrical detector placement in z)
0017 // 
0018 //==========================================================================
0019 #include "DD4hep/DetFactoryHelper.h"
0020 
0021 using namespace std;
0022 using namespace dd4hep;
0023 using namespace dd4hep::detail;
0024 
0025 static Ref_t create_detector(Detector& description, xml_h e, Ref_t sens)  {
0026   xml_det_t  x_det = e;
0027   string     name  = x_det.nameStr();
0028   DetElement sdet (name,x_det.id());
0029   Material   mat  (description.material(x_det.materialStr()));
0030   vector<double> rmin,rmax,z;
0031   int num = 0;
0032 
0033   for(xml_coll_t c(e,_U(zplane)); c; ++c, ++num)  {
0034     xml_comp_t dim(c);
0035     rmin.push_back(dim.rmin());
0036     rmax.push_back(dim.rmax());
0037     z.push_back(dim.z()); //Dropped division by 2 in z. Half length not needed
0038   }
0039   if ( num < 2 )  {
0040     throw runtime_error("PolyCone["+name+"]> Not enough Z planes. minimum is 2!");
0041   }
0042   Polycone   cone  (0,2*M_PI,rmin,rmax,z);
0043   Volume     det_vol(name, cone, mat);
0044   double z_offset = x_det.hasAttr(_U(z_offset)) ? x_det.z_offset() : 0.0;
0045     PlacedVolume pv = description.pickMotherVolume(sdet).placeVolume(det_vol,Position(0,0,z_offset));
0046 
0047   sdet.setPlacement(pv);
0048   det_vol.setVisAttributes(description, x_det.visStr());
0049   det_vol.setLimitSet(description, x_det.limitsStr());
0050   det_vol.setRegion(description, x_det.regionStr());
0051   if ( x_det.isSensitive() )   {
0052     SensitiveDetector sd = sens;
0053     xml_dim_t sd_typ = x_det.child(_U(sensitive));
0054     det_vol.setSensitiveDetector(sens);
0055     sd.setType(sd_typ.typeStr());
0056   }
0057 
0058   if ( x_det.hasAttr(_U(id)) )  {
0059     int det_id = x_det.id();
0060     pv.addPhysVolID("system",det_id);
0061   }
0062   return sdet;
0063 }
0064 
0065 DECLARE_DETELEMENT(Lhe_PolyconeSupport,create_detector)