Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:42

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 // Framework includes
0015 #include <DD4hep/DetFactoryHelper.h>
0016 #include <XML/Utilities.h>
0017 
0018 using namespace dd4hep;
0019 using namespace dd4hep::detail;
0020 
0021 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens)  {
0022   xml_dim_t x_det = e;  
0023   xml_comp_t xshape (x_det.child(_U(shape)));
0024   xml_dim_t  xpos   (x_det.child(_U(position), false));
0025   xml_elt_t  xmat   (x_det.child(_U(material)));
0026   xml_dim_t  xbox   (x_det.child(_U(box)));
0027   DetElement d_det(x_det.nameStr(),x_det.id());
0028   Volume assembly(x_det.nameStr()+"_vol", Box(xbox.x(), xbox.y(), xbox.z()), description.air());
0029   //Assembly  assembly(x_det.nameStr()+"_envelope");
0030   Material   mat    (description.material(xmat.attr<std::string>(_U(name))));
0031   Position   pos(xpos.x(),xpos.y(),xpos.z());
0032   Solid  sh  = xml::createShape(description, xshape.typeStr(), xshape);
0033   Volume vol = Volume(x_det.nameStr()+"_vol", sh, mat);
0034   PlacedVolume pv;
0035 
0036   for(xml_coll_t c(xshape,_U(property)); c; ++c)   {
0037     xml_elt_t ec = c;
0038     vol.addProperty(ec.attr<std::string>(_U(name)), ec.attr<std::string>(_U(value)));
0039   }
0040 
0041   sens.setType("calorimeter");
0042   vol.setVisAttributes(description, x_det.visStr());
0043   vol.setSensitiveDetector(sens);
0044 
0045   int ipos = 0;
0046   for(xml_coll_t c(xshape, _U(position)); c; ++c)   {
0047     xml_dim_t  xp = c;
0048     Position   vol_pos(xp.x(), xp.y(), xp.z());
0049     pv = assembly.placeVolume(vol, vol_pos);
0050     pv.addPhysVolID("module", ++ipos);
0051   }
0052 
0053   assembly.setVisAttributes(description, xbox.attr<std::string>(_U(vis)));
0054   pv = description.pickMotherVolume(d_det).placeVolume(assembly, pos);
0055   pv.addPhysVolID("system",x_det.id());
0056   d_det.setPlacement(pv);
0057   return d_det;
0058 }
0059 
0060 DECLARE_DETELEMENT(DD4hep_SingleShape,create_detector)